From 8b4f4f2e373896fcaa50f6ee55467274f8e440d5 Mon Sep 17 00:00:00 2001 From: Pablo Montenegro Date: Fri, 17 Nov 2023 10:22:21 -0300 Subject: [PATCH] [FIX] l10n_latam_invoice_document: prevent delete document number if invoice date is assigned. Task latam: 1137 Task Adhoc: 33333 Prevent delete document number if invoice date is assigned (manual documents). Description of the issue/feature this PR addresses: On a draft vendor bill (manual documents) if the document number setted, and then if the user set a date, the document number is automatically cleaned and it`s must not be cleaned. Current behavior before PR: On a draft vendor bill if the document number setted, and then if the user set a date, the document number is automatically cleaned. Desired behavior after PR is merged: On a draft vendor bill if the document number setted, and then if the user set a date, the document number is not automatically cleaned. closes odoo/odoo#147242 X-original-commit: 8212f7dd73028fa6c68819218e1e63fe60d71913 Signed-off-by: Josse Colpaert --- addons/l10n_latam_invoice_document/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_latam_invoice_document/models/account_move.py b/addons/l10n_latam_invoice_document/models/account_move.py index f5791590876..7568193a04a 100644 --- a/addons/l10n_latam_invoice_document/models/account_move.py +++ b/addons/l10n_latam_invoice_document/models/account_move.py @@ -82,7 +82,7 @@ class AccountMove(models.Model): when we change the document type) """ without_doc_type = self.filtered(lambda x: x.journal_id.l10n_latam_use_documents and not x.l10n_latam_document_type_id) manual_documents = self.filtered(lambda x: x.journal_id.l10n_latam_use_documents and x.l10n_latam_manual_document_number) - (without_doc_type + manual_documents.filtered(lambda x: not x.name or x.name and x.state == 'draft' and not x.posted_before)).name = '/' + (without_doc_type + manual_documents.filtered(lambda x: not x.name)).name = '/' # we need to group moves by document type as _compute_name will apply the same name prefix of the first record to the others group_by_document_type = defaultdict(self.env['account.move'].browse) for move in (self - without_doc_type - manual_documents):