[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 <jco@odoo.com>
This commit is contained in:
Katherine Zaoral
2022-03-31 17:25:02 +02:00
committed by Josse Colpaert
parent beb6e17066
commit 39db0eaff4
+8
View File
@@ -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: