diff options
| author | Katherine Zaoral <kz@adhoc.com.ar> | 2021-01-25 21:19:22 +0000 |
|---|---|---|
| committer | Katherine Zaoral <kz@adhoc.com.ar> | 2021-02-23 17:29:24 +0000 |
| commit | e87e5a17e09be77908f0d23b846d23d01f507423 (patch) | |
| tree | 85e758f8a763fd5ee75afa1235b418d447c2e4ce /addons/l10n_ar/models | |
| parent | bfc9153e79d90f1d10e86216bdc57c818b9b1395 (diff) | |
[ADD] l10n_ar: generic changes to use in QR code
AFIP give us new resolution 4291 that request to print QR code in
printed version of electronic invoices. For that we:
1) update the xml report footer style
2) add generic method to sanitze the identification number we are
sending, the sanitize method is added here in order to be re used for
other functionalities across electronic invoice and reports. If we are
not able to sanitize the number then we show an error to the user
3) update translations to add new raise message translated term
closes odoo/odoo#65033
Related: odoo/enterprise#15948
Signed-off-by: Josse Colpaert <jco@openerp.com>
Diffstat (limited to 'addons/l10n_ar/models')
| -rw-r--r-- | addons/l10n_ar/models/res_partner.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/addons/l10n_ar/models/res_partner.py b/addons/l10n_ar/models/res_partner.py index 416beaf1a4f..e7b089c8bac 100644 --- a/addons/l10n_ar/models/res_partner.py +++ b/addons/l10n_ar/models/res_partner.py @@ -2,6 +2,7 @@ from odoo import fields, models, api, _ from odoo.exceptions import UserError, ValidationError import stdnum.ar +import re import logging _logger = logging.getLogger(__name__) @@ -110,3 +111,14 @@ class ResPartner(models.Model): raise ValidationError(_('Only numbers allowed for "%s"', rec.l10n_latam_identification_type_id.name)) 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 """ + 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)) + else: + id_number = re.sub('[^0-9]', '', self.vat) + res = int(id_number) + return res |
