From c9b6c6b14ae9a0597b7640cd6969164c253c412b Mon Sep 17 00:00:00 2001 From: Martin Quinteros Date: Tue, 28 Jan 2025 17:18:01 -0300 Subject: [PATCH] [FIX] sale_order_type: Incompatibility with l10n_latam_check module This is a work-in-progress PR and is not yet finished. When adding a dependency to the _compute_journal_id method, it breaks the functionality of the l10n_latam_check module when calculating the l10n_latam_check_issuer_vat field during the creation of a third-party check payment. Steps to reproduce: Create a payment. Choose a third-party check journal. Modify the l10n_latam_check_issuer_vat issuer. Save the payment. The l10n_latam_check_issuer_vat field is recomputed. --- sale_order_type/models/account_move.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sale_order_type/models/account_move.py b/sale_order_type/models/account_move.py index efc0de8bec9..86f0214008e 100644 --- a/sale_order_type/models/account_move.py +++ b/sale_order_type/models/account_move.py @@ -48,9 +48,15 @@ def _compute_invoice_payment_term_id(self): move.invoice_payment_term_id = move.sale_type_id.payment_term_id return res - @api.depends("sale_type_id") - def _compute_journal_id(self): - res = super()._compute_journal_id() - for move in self.filtered("sale_type_id.journal_id"): - move.journal_id = move.sale_type_id.journal_id + def _search_default_journal(self): + res = super()._search_default_journal() + sale_type_journal_id = self.sale_type_id.journal_id + if sale_type_journal_id and sale_type_journal_id in self.suitable_journal_ids: + return sale_type_journal_id return res + + @api.onchange("sale_type_id") + def _onchange_sale_type_id(self): + sale_type_journal_id = self.sale_type_id.journal_id + if sale_type_journal_id and sale_type_journal_id in self.suitable_journal_ids: + self.journal_id = sale_type_journal_id.id