From bdcf5b6c2a5645572864a638afea260cd7cd225a Mon Sep 17 00:00:00 2001 From: Jinjiu Liu Date: Tue, 28 Feb 2023 14:06:18 +0000 Subject: [PATCH] =?UTF-8?q?[FIX]=20account:=20don=E2=80=99t=20compute=20jo?= =?UTF-8?q?urnal=20id=20if=20default=20value=20is=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reproduction: 1. Go to settings -> Technical -> user-defined defaults, create a default for sales type Journal for an account.move 2. Go to Accounting-> Customer -> payment, create a payment, and select Bank for jounal 3. The payment method is not changed to Manual, in V15 it does Reason: from Odoo 16.0, the method new is added to account_payment, and we compute the journal id when it’s not set. However, this doesn’t consider the case where we have a default value for journal_id. Currently, when there’s a default value, we still compute the journal id This causes the onchange, which uses record created by method new, is not triggered when we select the journal id as the computed journal id, e.g bank. Fix: don’t compute journal id when there’s a default value for it PR of adding the new method (big PR for 16): https://github.com/odoo/odoo/pull/96134 opw-3148919 closes odoo/odoo#116082 X-original-commit: 05aa0726529132df5733a3db61e4c3da1c037c1d Signed-off-by: Cedric Snauwaert Signed-off-by: Liu Jinjiu (jili) --- addons/account/models/account_payment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 42c8cec74bb..960de318d93 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -674,7 +674,7 @@ class AccountPayment(models.Model): def new(self, values=None, origin=None, ref=None): payment = super().new(values, origin, ref) - if not payment.journal_id: # might not be computed because declared by inheritance + if not payment.journal_id and not payment.default_get(['journal_id']): # might not be computed because declared by inheritance payment.move_id.payment_id = payment payment.move_id._compute_journal_id() return payment