From b0eed54cd015b0cd40a54ed0569354deadffa39f Mon Sep 17 00:00:00 2001 From: "John Laterre (jol)" Date: Tue, 8 Feb 2022 10:09:50 +0000 Subject: [PATCH] [FIX] account: fix account type constraint on bank journals The issue here is to be able to change the type of bank account on the bank journal, e.g. changing from type "Current Assets" to "Bank and Cash". Previously, a ValidationError would be raised : "This account is configured in %(journal_names)s journal(s) (ids %(journal_ids)s) as payment debit or credit account. This means that this account's type should be reconcilable." But in some cases, the client might decided not to reconcile. And the error did not take into account the case when the bank account and the outstanding accounts are the same. opw-2738777 closes odoo/odoo#85370 X-original-commit: fe379bc22e649c623dfb6ed8aefb106b4846d02e Signed-off-by: Laurent Smet Signed-off-by: John Laterre --- addons/account/models/account_account.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_account.py b/addons/account/models/account_account.py index bb66ea601a6..15a6fc5181d 100644 --- a/addons/account/models/account_account.py +++ b/addons/account/models/account_account.py @@ -246,9 +246,16 @@ class AccountAccount(models.Model): FROM account_journal journal JOIN res_company company on journal.company_id = company.id LEFT JOIN account_payment_method_line apml ON journal.id = apml.journal_id - WHERE company.account_journal_payment_credit_account_id in %(accounts)s - OR company.account_journal_payment_debit_account_id in %(accounts)s - OR apml.payment_account_id in %(accounts)s + WHERE ( + company.account_journal_payment_credit_account_id IN %(accounts)s + AND company.account_journal_payment_credit_account_id != journal.default_account_id + ) OR ( + company.account_journal_payment_debit_account_id in %(accounts)s + AND company.account_journal_payment_debit_account_id != journal.default_account_id + ) OR ( + apml.payment_account_id IN %(accounts)s + AND apml.payment_account_id != journal.default_account_id + ) ''', { 'accounts': tuple(accounts.ids), })