[FIX] l10n_ar: Fix ImportError: No module named 'stdnum.ar.cbu'

Since stdnum.ar.cbu is not available in odoo saas enviroment because is
using an old version of stdnum package, we add a try exept in order to
catch this and manage the error properly which is raise an exception and
leave a message in the log telling the user that the cbu was not able to
validate.

closes odoo/odoo#40383

X-original-commit: 25d483fc3fc05fd47c72c3d96c02fed12b998b0d
Signed-off-by: Josse Colpaert <jco@openerp.com>
This commit is contained in:
Katherine Zaoral
2019-11-15 21:15:01 +00:00
committed by fw-bot
parent c0e5f821ce
commit 91f503cd99
+10 -2
View File
@@ -1,10 +1,18 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, api, _
import stdnum.ar.cbu
from odoo.exceptions import ValidationError
import stdnum.ar
import logging
_logger = logging.getLogger(__name__)
def validate_cbu(cbu):
return stdnum.ar.cbu.validate(cbu)
try:
return stdnum.ar.cbu.validate(cbu)
except Exception as error:
msg = _("Argentinian CBU was not validated: %s" % repr(error))
_logger.log(25, msg)
raise ValidationError(msg)
class ResPartnerBank(models.Model):