[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) <nle@odoo.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: pvh-odoo <SwagSamaSempai@users.noreply.github.com>
This commit is contained in:
Philémon van Helden
2021-08-20 15:03:32 +00:00
parent 907c8442a1
commit c976d3765c
+10 -3
View File
@@ -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