From 9556813ff948b4a7567a7dd6d3fbd78e9e0d74c7 Mon Sep 17 00:00:00 2001 From: "Thomas Becquevort (thbe)" Date: Thu, 21 Sep 2023 11:23:14 +0000 Subject: [PATCH] [IMP] base_vat: Allow T as country code for JP companies Tax ID Description of the issue/feature this commit addresses: As of the first October 2023, some Japanese companies will start using "T" as country code in their Tax ID. The current vat check only allows the country code to be used in the Tax ID which means that "T" is refused. Desired behavior after the commit is merged : This commit makes it possible for Japanese companies to use "T" as a country code in their Tax ID. task-3515786 closes odoo/odoo#137455 X-original-commit: 114e31521beb1d00f85f8a19959006dfe62708a0 Signed-off-by: Quentin De Paoli Signed-off-by: Thomas Becquevort (thbe) --- addons/base_vat/models/res_partner.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/base_vat/models/res_partner.py b/addons/base_vat/models/res_partner.py index 0d3f13b4afc..0b817e6f656 100644 --- a/addons/base_vat/models/res_partner.py +++ b/addons/base_vat/models/res_partner.py @@ -83,6 +83,7 @@ _ref_vat = { _region_specific_vat_codes = { 'xi', + 't', } @@ -101,7 +102,14 @@ class ResPartner(models.Model): vies_vat_to_check = fields.Char(compute='_compute_vies_vat_to_check') def _split_vat(self, vat): - vat_country, vat_number = vat[:2].lower(), vat[2:].replace(' ', '') + ''' + Splits the VAT Number to get the country code in a first place and the code itself in a second place. + This has to be done because some countries' code are one character long instead of two (i.e. "T" for Japan) + ''' + if vat[1].isalpha(): + vat_country, vat_number = vat[:2].lower(), vat[2:].replace(' ', '') + else: + vat_country, vat_number = vat[:1].lower(), vat[1:].replace(' ', '') return vat_country, vat_number @api.model @@ -691,6 +699,10 @@ class ResPartner(models.Model): check_func = stdnum.util.get_cc_module('nz', 'ird').is_valid return check_func(vat) + def check_vat_t(self, vat): + if self.country_id.code == 'JP': + return self.simple_vat_check('jp', 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.