diff --git a/base_vat_optional_vies/__manifest__.py b/base_vat_optional_vies/__manifest__.py index a36564bac8b..14e26901f13 100644 --- a/base_vat_optional_vies/__manifest__.py +++ b/base_vat_optional_vies/__manifest__.py @@ -10,6 +10,7 @@ "category": "Accounting", "version": "14.0.2.1.0", "depends": ["base_vat"], + "external_dependencies": {"python": ["zeep"]}, "data": [ "views/res_partner_view.xml", "views/res_config_settings_views.xml", diff --git a/base_vat_optional_vies/models/res_partner.py b/base_vat_optional_vies/models/res_partner.py index b8324b07c1c..2f48ec815c7 100644 --- a/base_vat_optional_vies/models/res_partner.py +++ b/base_vat_optional_vies/models/res_partner.py @@ -4,10 +4,16 @@ # Copyright 2022 Moduon - Eduardo de Miguel # Copyright 2023 Moduon - Emilio Pascual # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import _, api, fields, models +import logging + +from zeep.exceptions import Fault + +from odoo import _, api, fields, models, tools from odoo.addons.base_vat.models.res_partner import _ref_vat +_logger = logging.getLogger(__name__) + class ResPartner(models.Model): _inherit = "res.partner" @@ -56,3 +62,19 @@ def _construct_constraint_msg(self, country_code): country_code, "'CC##' (CC=Country Code, ##=VAT Number)" ), ) + + @api.model + @tools.ormcache("vat") + def _check_vies(self, vat): + # Check for error of connection + try: + return super()._check_vies(vat) + except Fault as error: + if error.args[0] == "MS_MAX_CONCURRENT_REQ": + logging.info( + "VIES VAT check not available at this moment as max concurrency " + "requests has been reached." + ) + if error.args[0] == "MS_UNAVAILABLE": + logging.info("VIES VAT check not available at this moment.") + return False diff --git a/base_vat_optional_vies/static/description/index.html b/base_vat_optional_vies/static/description/index.html index b8f7cd33f4a..2bc51907485 100644 --- a/base_vat_optional_vies/static/description/index.html +++ b/base_vat_optional_vies/static/description/index.html @@ -1,4 +1,3 @@ - diff --git a/requirements.txt b/requirements.txt index 965eea8aa65..6c15a087faf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ # generated from manifests external_dependencies numpy-financial<=1.0.0 numpy>=1.15 +zeep