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: