From 4380e3b9cfd44a7c432af63d906aaef3a8b70f2d Mon Sep 17 00:00:00 2001 From: Saurabh Mishra Date: Wed, 19 Jul 2023 07:16:19 +0000 Subject: [PATCH] [FIX] base_vat: log a warning when VAT is invalid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While creating a customer, if the user selects France as the customer's country and then enters an invalid input into the VAT field, such as (FR), which is not a valid input required, the user will encounter an error. steps to produce: - Install base_vat. - Invoicing > Settings under Taxes check Verify VAT Numbers. - Invoicing > Settings > Customers create a new customer, enter name, country as France, an invalid input in VAT eg. (FR) Error: `Fault: INVALID_INPUT` This commit changes the exception to a warning since this issue will be encountered every time the user enters an invalid input into VAT. Although we have handled it with a Validation Error and added a note in Odoo, a traceback is generated everytime. Therefore, to handle this, the exception is changed to a warning. sentry-4234933702 closes odoo/odoo#132491 X-original-commit: a5b88f483977c478f26bc224bfea115da1e63819 Signed-off-by: de Wouters de Bouchout Jean-BenoƮt (jbw) Signed-off-by: Saurabh Mishra (sami) --- addons/base_vat/models/res_partner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/base_vat/models/res_partner.py b/addons/base_vat/models/res_partner.py index d31a8baf931..4594bad3b99 100644 --- a/addons/base_vat/models/res_partner.py +++ b/addons/base_vat/models/res_partner.py @@ -3,6 +3,7 @@ import datetime import string +import zeep import re import stdnum from stdnum.eu.vat import check_vies @@ -199,7 +200,7 @@ class ResPartner(models.Model): try: vies_valid = check_vies(partner.vies_vat_to_check, timeout=10) partner.vies_valid = vies_valid['valid'] - except Exception as e: + except (OSError, InvalidComponent, zeep.exceptions.Fault) as e: if partner._origin.id: msg = "" if isinstance(e, OSError): @@ -207,7 +208,7 @@ class ResPartner(models.Model): elif isinstance(e, InvalidComponent): msg = _("The VAT number %s could not be interpreted by the VIES server.", partner.vies_vat_to_check) partner._origin.message_post(body=msg) - _logger.exception("The VAT number %s failed VIES check.", partner.vies_vat_to_check) + _logger.warning("The VAT number %s failed VIES check.", partner.vies_vat_to_check) partner.vies_valid = False @api.model