[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) <vin@odoo.com>
This commit is contained in:
Laurent Smet
2023-01-19 07:11:42 +01:00
parent 280a43bf20
commit 32fd54f945
@@ -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)