From 39db0eaff4e691dde7eb512201aed57ee20ea686 Mon Sep 17 00:00:00 2001 From: Katherine Zaoral Date: Fri, 18 Feb 2022 22:34:03 +0000 Subject: [PATCH] [FIX] l10n_ar: share sequences compute sequences Before this change, we have the errors that documents generated on pre-printed sales journals mark as unified book were wrongly named using the wrong doc prefix code. This was visible thanks to the demo data were we notices that the credit notes were having FA- doc prefix instead of NC- This was because we are reusing the shared sequence directly, now we check and fix the doc prefix for those cases and all documents generated on shared sequences are properly named. closes odoo/odoo#86612 X-original-commit: df5bfd22c20d3a3bd72b04acbdae63657e025ce3 Signed-off-by: Josse Colpaert --- addons/l10n_ar/models/account_move.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/l10n_ar/models/account_move.py b/addons/l10n_ar/models/account_move.py index 14075def91a..21d5a8ed6dc 100644 --- a/addons/l10n_ar/models/account_move.py +++ b/addons/l10n_ar/models/account_move.py @@ -240,6 +240,14 @@ class AccountMove(models.Model): return self._get_formatted_sequence() return super()._get_starting_sequence() + def _get_last_sequence(self, relaxed=False, with_prefix=None): + """ If use share sequences we need to recompute the sequence to add the proper document code prefix """ + res = super()._get_last_sequence(relaxed=relaxed, with_prefix=with_prefix) + if res and self.journal_id.l10n_ar_share_sequences and self.l10n_latam_document_type_id.doc_code_prefix not in res: + res = self._get_formatted_sequence(number=self._l10n_ar_get_document_number_parts( + res.split()[-1], self.l10n_latam_document_type_id.code)['invoice_number']) + return res + def _get_last_sequence_domain(self, relaxed=False): where_string, param = super(AccountMove, self)._get_last_sequence_domain(relaxed) if self.company_id.account_fiscal_country_id.code == "AR" and self.l10n_latam_use_documents: