diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index f1fabf4d233..8301370bd8d 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -667,6 +667,35 @@ class ResPartner(models.Model): raise e _logger.debug('Another transaction already locked partner rows. Cannot update partner ranks.') + @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() + + @api.model + def _build_vat_error_message(self, country_code, wrong_vat, record_label): + """ Prepare an error message for the VAT number that failed validation + + :param country_code: string of lowercase country code + :param wrong_vat: the vat number that was validated + :param record_label: a string to desribe the record that failed a VAT validation check + + :return: The error message string + """ + return "" + @api.model def get_partner_localisation_fields_required_to_invoice(self, country_id): """ Returns the list of fields that needs to be filled when creating an invoice for the selected country. diff --git a/addons/base_vat/models/res_partner.py b/addons/base_vat/models/res_partner.py index 0f3f350392b..ab6c33d68c4 100644 --- a/addons/base_vat/models/res_partner.py +++ b/addons/base_vat/models/res_partner.py @@ -192,21 +192,7 @@ class ResPartner(models.Model): @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. - A first check is made by using the first two characters of the VAT as - the country code. If 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. - .. 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. - """ + # OVERRIDE account check_result = None # First check with country code as prefix of the TIN @@ -256,6 +242,7 @@ class ResPartner(models.Model): @api.model def _build_vat_error_message(self, country_code, wrong_vat, record_label): + # OVERRIDE account if self.env.context.get('company_id'): company = self.env['res.company'].browse(self.env.context['company_id']) else: