From 32fd54f9452685a7f8a3add05058701bac65e1d0 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Fri, 13 Jan 2023 10:19:18 +0000 Subject: [PATCH] [FIX] account: Fix dashboard traceback with journal without account Traceback when opening the accounting dashboard with a journal having no default_account_id. default_account_id = false ...is not a valid sql where_clause closes odoo/odoo#110098 X-original-commit: ae71a4c255e995b5d232cb837e2879454bf30a52 Signed-off-by: Nicolas Viseur (vin) --- .../models/account_journal_dashboard.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py index e87ccd6f80a..6b766286f82 100644 --- a/addons/account/models/account_journal_dashboard.py +++ b/addons/account/models/account_journal_dashboard.py @@ -276,18 +276,21 @@ class account_journal(models.Model): outstanding_pay_account_balance, nb_lines_outstanding_pay_account_balance = self._get_journal_outstanding_payments_account_balance( domain=[('parent_state', '=', 'posted')]) - self._cr.execute(''' - 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' - AND aml.account_id = %s - ''', [tuple(self.ids), self.default_account_id.id]) - number_to_reconcile = self.env.cr.fetchone()[0] + if self.default_account_id: + self._cr.execute(''' + 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' + AND aml.account_id = %s + ''', [tuple(self.ids), self.default_account_id.id]) + number_to_reconcile = self.env.cr.fetchone()[0] + else: + number_to_reconcile = 0 to_check_ids = self.to_check_ids() number_to_check = len(to_check_ids)