[FIX] base_vat: log a warning when VAT is invalid
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) <jbw@odoo.com> Signed-off-by: Saurabh Mishra (sami) <sami@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user