mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[9.0][FIX] account_fiscal_position_vat_check: vat required not check in partner form (#432)
This commit is contained in:
committed by
Pedro M. Baeza
parent
4c8e2e7807
commit
72e734536b
@@ -9,11 +9,11 @@ from openerp import models, api, _
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
@api.onchange('property_account_position')
|
||||
@api.onchange('property_account_position_id')
|
||||
def fiscal_position_change(self):
|
||||
"""Warning if the fiscal position requires a VAT number and the
|
||||
partner doesn't have one yet"""
|
||||
fp = self.property_account_position
|
||||
fp = self.property_account_position_id
|
||||
if fp.customer_must_have_vat and self.customer and not self.vat:
|
||||
return {
|
||||
'warning': {
|
||||
|
||||
3
account_fiscal_position_vat_check/tests/__init__.py
Normal file
3
account_fiscal_position_vat_check/tests/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import test_account_fiscal_position_vat_check
|
||||
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Laurent Bélorgey <lb@lalieutenante.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from openerp.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestAccountFiscalPositionVatCheck(TransactionCase):
|
||||
def test_partner_must_have_vat_check(self):
|
||||
fp = self.env['account.fiscal.position'].create({
|
||||
'name': 'Test',
|
||||
'customer_must_have_vat': True})
|
||||
customer = self.env['res.partner'].search(
|
||||
[('customer', '=', True)], limit=1)
|
||||
customer.write({'property_account_position_id': fp.id})
|
||||
res = customer.fiscal_position_change()
|
||||
self.assertEqual(res['warning']['title'], 'Missing VAT number:')
|
||||
fp.write({'customer_must_have_vat': False})
|
||||
res = customer.fiscal_position_change()
|
||||
self.assertFalse(res)
|
||||
Reference in New Issue
Block a user