From d1b9c2f3771213916ebb00f85ba4d0423ab0aff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Gonz=C3=A1lez?= Date: Mon, 11 Feb 2019 15:57:38 +0000 Subject: [PATCH] [FIX] account: Journal is overwritteng in payments by onchange There is an onchange on payments that, when the currency is modified, sets the journal to the first available one whose currency matches the selected one. However, if a journal is already set, its value is overwritten, even if its currency matches the new one. To replicate: - Create two banks in EUR - Create an internal transfer from the second bank - Set the payment currency to EUR When you follow the above steps, the payment journal will be incorrectly set to the first bank. Other possible ways to replicate the issue are: - When editing a payment already created whose journal is correct but whose currency is not - When creating a payment and the journal is set before the currency This commit fixes that issue by preventing the onchange from modifying the journal, when it's already set. Closes odoo/odoo#30967 closes odoo/odoo#30969 --- addons/account/models/account_payment.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 4716a188ca1..67de2424d9c 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -211,6 +211,8 @@ class account_abstract_payment(models.AbstractModel): self.amount = abs(self._compute_payment_amount()) # Set by default the first liquidity journal having this currency if exists. + if self.journal_id: + return journal = self.env['account.journal'].search( [('type', 'in', ('bank', 'cash')), ('currency_id', '=', self.currency_id.id)], limit=1) if journal: