From 629f292b047ce3f2669d9c4bcce7ef2a37c35650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tanguy=20Qu=C3=A9guineur?= Date: Wed, 6 Mar 2024 10:00:12 +0100 Subject: [PATCH] [FIX] account: hide misc amount in case of different currencies Steps: ------ 1. Have accounting installed. 2. Have a bank journal with a currency different from company's currency, use a bank account with no currency set for this bank journal. 3. Make a misc operation in the bank account used by the journal. 4. On the dashboard, the "Misc. Operations" amount will not be converted to the journal's currency, even though the currency's symbol is correct, the amount is in the company's currency. Fix --- Do not show the total amount of misc operations if the bank journal and bank journal's bank account currencies are not matching. The user still knows there are journal entries not linked to a bank transaction thanks to the "misc operations" text, but we avoid doing a currency conversion that may not make sense. opw-3767010 closes odoo/odoo#156655 Signed-off-by: Florian Gilbert (flg) --- addons/account/models/account_journal_dashboard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py index 2ffcddcd719..08b8b32938a 100644 --- a/addons/account/models/account_journal_dashboard.py +++ b/addons/account/models/account_journal_dashboard.py @@ -423,6 +423,7 @@ class account_journal(models.Model): has_outstanding, outstanding_pay_account_balance = outstanding_pay_account_balances[journal.id] to_check_balance, number_to_check = to_check.get(journal, (0, 0)) misc_balance, number_misc = misc_totals.get(journal.default_account_id, (0, 0)) + currency_consistent = not journal.currency_id or journal.currency_id == journal.default_account_id.currency_id accessible = journal.company_id.id in journal.company_id._accessible_branches().ids dashboard_data[journal.id].update({ @@ -439,7 +440,7 @@ class account_journal(models.Model): 'bank_statements_source': journal.bank_statements_source, 'is_sample_data': journal.has_statement_lines, 'nb_misc_operations': number_misc, - 'misc_operations_balance': currency.format(misc_balance), + 'misc_operations_balance': currency.format(misc_balance) if currency_consistent else None, }) def _fill_sale_purchase_dashboard_data(self, dashboard_data):