diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index 70f68c4188681ad08087a0395b4709cc64e30a4c..2b1c2964a8d79392978628eccda584051226bbd2 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -584,6 +584,21 @@ class ResPartner(models.Model): else: raise e + @api.model + def _run_vat_test(self, vat_number, default_country, partner_is_company=True): + """ Checks a VAT number syntactically to ensure its validity upon saving. + :param vat_number: a string with the VAT number to check. + :param default_country: a res.country object + :param partner_is_company: True if the partner is a company, else False. + .. deprecated:: 16.0 + Will be removed in 16.2 + :return: The country code (in lower case) of the country the VAT number + was validated for, if it was validated. False if it could not be validated + against the provided or guessed country. None if no country was available + for the check, and no conclusion could be made with certainty. + """ + return default_country.code.lower() + def _merge_method(self, destination, source): """ Prevent merging partners that are linked to already hashed journal items. diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py index 54ccc719e79d71c6eb2cee4842dc93a2fbf1d61d..7b5afbcfa9442adbf2e23562cca57f071ed78959 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py @@ -261,7 +261,8 @@ class AccountEdiXmlCII(models.AbstractModel): mail = _find_value(f"//ram:{role}//ram:URIID[@schemeID='SMTP']") vat = _find_value(f"//ram:{role}/ram:SpecifiedTaxRegistration/ram:ID") phone = _find_value(f"//ram:{role}/ram:DefinedTradeContact/ram:TelephoneUniversalCommunication/ram:CompleteNumber") - self._import_retrieve_and_fill_partner(invoice_form, name=name, phone=phone, mail=mail, vat=vat) + country_code = _find_value(f'//ram:{role}/ram:PostalTradeAddress//ram:CountryID') + self._import_retrieve_and_fill_partner(invoice_form, name=name, phone=phone, mail=mail, vat=vat, country_code=country_code) # ==== currency_id ==== diff --git a/addons/base_vat/models/res_partner.py b/addons/base_vat/models/res_partner.py index cfc6299c1129520617402bd7d9e008bb1b7dd1fe..4140e9273bdb091cdeb8a852a726155ca7f9bee2 100644 --- a/addons/base_vat/models/res_partner.py +++ b/addons/base_vat/models/res_partner.py @@ -166,20 +166,7 @@ class ResPartner(models.Model): @api.model def _run_vat_test(self, vat_number, default_country, partner_is_company=True): - """ Checks a VAT number, either syntactically or using VIES, depending - on the active company's configuration. - A first check is made by using the first two characters of the VAT as - the country code. It it fails, a second one is made using default_country instead. - - :param vat_number: a string with the VAT number to check. - :param default_country: a res.country object - :param partner_is_company: True if the partner is a company, else False - - :return: The country code (in lower case) of the country the VAT number - was validated for, if it was validated. False if it could not be validated - against the provided or guessed country. None if no country was available - for the check, and no conclusion could be made with certainty. - """ + # OVERRIDE account # Get company if self.env.context.get('company_id'): company = self.env['res.company'].browse(self.env.context['company_id'])