From 924ffcaa5264b398e82b3a96a2bbcaab665bc810 Mon Sep 17 00:00:00 2001 From: "Guillaume (guva)" Date: Tue, 6 Dec 2022 12:57:38 +0000 Subject: [PATCH] [FIX] account: adapt query for items to reconcile Changing the bank account on the bank journal led to a traceback (expected singleton on currency_id) when trying to open the reconciliation widget. This is because we are trying to open a blank line as the origin line was linked to the origin Bank account, therefore there is no currency_id. It has been decided to filter the statement line that match the bank account and to adapt the action button. Steps to reproduce: - Create a bank statement line - In Bank journal, change the Bank Account - From Accounting Dashboard, click on "Reconcile X items" or just open the Bank Journal -> Traceback (expected singleton) opw-3085670 closes odoo/odoo#107441 X-original-commit: c566a48c5bc528a140e6f29399ca1fbcede60490 Related: odoo/enterprise#34762 Signed-off-by: Quentin De Paoli Signed-off-by: Guillaume Vanleynseele (guva) --- addons/account/models/account_journal_dashboard.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py index fd6829ec88f..e87ccd6f80a 100644 --- a/addons/account/models/account_journal_dashboard.py +++ b/addons/account/models/account_journal_dashboard.py @@ -280,11 +280,13 @@ class account_journal(models.Model): SELECT COUNT(st_line.id) FROM account_bank_statement_line st_line JOIN account_move st_line_move ON st_line_move.id = st_line.move_id + JOIN account_move_line aml ON aml.move_id = st_line_move.id WHERE st_line_move.journal_id IN %s AND NOT st_line.is_reconciled AND st_line_move.to_check IS NOT TRUE AND st_line_move.state = 'posted' - ''', [tuple(self.ids)]) + AND aml.account_id = %s + ''', [tuple(self.ids), self.default_account_id.id]) number_to_reconcile = self.env.cr.fetchone()[0] to_check_ids = self.to_check_ids()