From f4026cb2d1f8589135fce1156dbd74c57843a44a Mon Sep 17 00:00:00 2001 From: Katherine Zaoral Date: Thu, 23 Jan 2020 21:00:54 +0000 Subject: [PATCH] [ADD] l10n_ar: use 5 digits pos number instead of 4 The law itself said that you can use 4 or 5 digits, but some customers complains that they want 5 (for eg. 00001) because some suppliers reject the invoice if only 4 digits (that is wrong, but suppliers do anything to avoid paying). We've check and AFIP online invoices use 5 digits always. So, to satisfy customers/suppliers and make code simpler, we think using 5 digits is a better option. X-original-commit: a475de89568c8274bb556d672948b25a95996599 --- addons/l10n_ar/models/account_journal.py | 3 +-- addons/l10n_ar/models/l10n_latam_document_type.py | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/l10n_ar/models/account_journal.py b/addons/l10n_ar/models/account_journal.py index 4690aefe71c..d8f501e5db6 100644 --- a/addons/l10n_ar/models/account_journal.py +++ b/addons/l10n_ar/models/account_journal.py @@ -185,5 +185,4 @@ class AccountJournal(models.Model): we add or not a prefix to identify sales journal. """ if self.type == 'sale' and self.l10n_ar_afip_pos_number: - pos_num = str(self.l10n_ar_afip_pos_number) - self.code = pos_num if len(pos_num) > 4 else _('S') + "%04d" % self.l10n_ar_afip_pos_number + self.code = "%05i" % self.l10n_ar_afip_pos_number diff --git a/addons/l10n_ar/models/l10n_latam_document_type.py b/addons/l10n_ar/models/l10n_latam_document_type.py index fd0b62e3735..37f695f3de8 100644 --- a/addons/l10n_ar/models/l10n_latam_document_type.py +++ b/addons/l10n_ar/models/l10n_latam_document_type.py @@ -38,7 +38,7 @@ class L10nLatamDocumentType(models.Model): if self.country_id != self.env.ref('base.ar'): return values - values.update({'padding': 8, 'implementation': 'no_gap', 'prefix': "%04i-" % (journal.l10n_ar_afip_pos_number), + values.update({'padding': 8, 'implementation': 'no_gap', 'prefix': "%05i-" % (journal.l10n_ar_afip_pos_number), 'l10n_latam_journal_id': journal.id}) if journal.l10n_ar_share_sequences: values.update({'name': '%s - Letter %s Documents' % (journal.name, self.l10n_ar_letter), @@ -85,9 +85,7 @@ class L10nLatamDocumentType(models.Model): failed = True elif len(number) > 8 or not number.isdigit(): failed = True - if len(pos) == 5 and pos[0] == '0': - pos = pos[1:] - document_number = '{:>04s}-{:>08s}'.format(pos, number) + document_number = '{:>05s}-{:>08s}'.format(pos, number) if failed: raise UserError(msg % (document_number, self.name, _( 'The document number must be entered with a dash (-) and a maximum of 5 characters for the first part'