[FIX] base_vat: Fix vat number starting with 'EU' for not-EU companies
Foreign companies that trade with non-enterprises in the EU may have a VATIN starting with "EU" instead of a country code. Currently, the user is facing a traceback in this situation since stdnum doesn't have any format method for vat number starting with 'EU'. closes odoo/odoo#93536 Ticket: 2877716 X-original-commit: 0f9f8409b379e3a0af28cecd3ed26829b9b26032 Signed-off-by: Olivier Colson (oco) <oco@odoo.com> Signed-off-by: Laurent Smet <las@odoo.com>
This commit is contained in:
@@ -577,6 +577,11 @@ class ResPartner(models.Model):
|
||||
return len(vat) == 11 and vat.isdigit()
|
||||
return check_func(vat)
|
||||
|
||||
def format_vat_eu(self, vat):
|
||||
# Foreign companies that trade with non-enterprises in the EU
|
||||
# may have a VATIN starting with "EU" instead of a country code.
|
||||
return vat
|
||||
|
||||
def format_vat_ch(self, vat):
|
||||
stdnum_vat_format = getattr(stdnum.util.get_cc_module('ch', 'vat'), 'format', None)
|
||||
return stdnum_vat_format('CH' + vat)[2:] if stdnum_vat_format else vat
|
||||
|
||||
@@ -80,6 +80,13 @@ class TestStructure(TransactionCase):
|
||||
# (for technical reasons due to ORM and res.company making related fields towards res.partner for country_id and vat)
|
||||
test_partner.write({'vat': '0477472701', 'country_id': None})
|
||||
|
||||
def test_vat_eu(self):
|
||||
""" Foreign companies that trade with non-enterprises in the EU may have a VATIN starting with "EU" instead of
|
||||
a country code.
|
||||
"""
|
||||
test_partner = self.env['res.partner'].create({'name': "Turlututu", 'country_id': self.env.ref('base.fr').id})
|
||||
test_partner.write({'vat': "EU528003646", 'country_id': None})
|
||||
|
||||
|
||||
@tagged('-standard', 'external')
|
||||
class TestStructureVIES(TestStructure):
|
||||
|
||||
Reference in New Issue
Block a user