[9.0][FIX] account_fiscal_position_vat_check: vat required not check in partner form (#432)

This commit is contained in:
Laurent Bélorgey
2017-01-07 17:09:15 +01:00
committed by Pedro M. Baeza
parent 4c8e2e7807
commit 72e734536b
3 changed files with 24 additions and 2 deletions

View File

@@ -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': {

View 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

View File

@@ -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)