From c976d3765c4a45824fc2fcb11b32b37e201711c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phil=C3=A9mon=20van=20Helden?= Date: Tue, 29 Jun 2021 10:15:26 +0000 Subject: [PATCH] [FIX] base_vat: properly checks XI VAT numbers In 12.0+ when adding an XI (Northern Ireland) VAT number on a vendor and specifying the country as United Kingdom, an error shows the VAT number as not valid. This is because the method to check specifically XI VAT numbers doesn't recognize XI as a country, and thus uses the GB VAT number verification, which doesn't recognize XI VAT numbers as it isn't up to date yet. A temporary method to check XI VAT number was already added, but is never called because XI is not recognized as a country code. With this commit, we add a list of known legitimate country codes, that are not considered as such in Odoo. opw-2534541 closes odoo/odoo#75399 X-original-commit: 3a1671470b71892dba3eade8f861faaa9689713e Signed-off-by: Nicolas Lempereur (nle) Signed-off-by: oco-odoo Signed-off-by: pvh-odoo --- addons/base_vat/models/res_partner.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/base_vat/models/res_partner.py b/addons/base_vat/models/res_partner.py index af0f09ac077..c6dc7d5cd19 100644 --- a/addons/base_vat/models/res_partner.py +++ b/addons/base_vat/models/res_partner.py @@ -69,7 +69,12 @@ _ref_vat = { 'si': 'SI12345679', 'sk': 'SK2022749619', 'sm': 'SM24165', - 'tr': 'TR1234567890 (VERGINO) or TR17291716060 (TCKIMLIKNO)' # Levent Karakas @ Eska Yazilim A.S. + 'tr': 'TR1234567890 (VERGINO) or TR17291716060 (TCKIMLIKNO)', # Levent Karakas @ Eska Yazilim A.S. + 'xi': 'XI123456782', +} + +_region_specific_vat_codes = { + 'xi', } @@ -179,8 +184,10 @@ class ResPartner(models.Model): # First check with country code as prefix of the TIN vat_country_code, vat_number_split = self._split_vat(vat_number) - vat_guessed_country = self.env['res.country'].search([('code', '=', vat_country_code.upper())]) - if vat_guessed_country: + vat_has_legit_country_code = self.env['res.country'].search([('code', '=', vat_country_code.upper())]) + if not vat_has_legit_country_code: + vat_has_legit_country_code = vat_country_code.lower() in _region_specific_vat_codes + if vat_has_legit_country_code: check_result = check_func(vat_country_code, vat_number_split) if check_result: return vat_country_code