[FIX] account: don’t compute journal id if default value is set

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 <csn@odoo.com>
Signed-off-by: Liu Jinjiu (jili) <jili@odoo.com>
This commit is contained in:
Jinjiu Liu
2023-03-22 15:59:06 +01:00
parent 02fb94aafb
commit bdcf5b6c2a
+1 -1
View File
@@ -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