From 69e31db6ac90874ed6329599fca8f09709efd119 Mon Sep 17 00:00:00 2001 From: Katherine Zaoral Date: Thu, 17 Feb 2022 00:32:39 +0000 Subject: [PATCH] [IMP] l10n_ar:_sanitize vat number method * fix traceback when vat is not defined, return directly 0. * remove api.model * add ensure_one() to avoid misuse of the method closes odoo/odoo#84952 X-original-commit: 5cd4df745462fcc12b9d92def9cf903ebd0df143 Related: odoo/enterprise#24565 Signed-off-by: Josse Colpaert --- addons/l10n_ar/models/res_partner.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/l10n_ar/models/res_partner.py b/addons/l10n_ar/models/res_partner.py index 4ea0ca609da..914ef74c15e 100644 --- a/addons/l10n_ar/models/res_partner.py +++ b/addons/l10n_ar/models/res_partner.py @@ -113,9 +113,12 @@ class ResPartner(models.Model): except Exception as error: raise ValidationError(repr(error)) - @api.model def _get_id_number_sanitize(self): - """ Sanitize the identification number. Return the digits/integer value of the identification number """ + """ Sanitize the identification number. Return the digits/integer value of the identification number + If not vat number defined return 0 """ + self.ensure_one() + if not self.vat: + return 0 if self.l10n_latam_identification_type_id.l10n_ar_afip_code in ['80', '86']: # Compact is the number clean up, remove all separators leave only digits res = int(stdnum.ar.cuit.compact(self.vat))