From 9d869836178685663ceb85289cce98bbb404a4a9 Mon Sep 17 00:00:00 2001 From: "Habib (ayh)" Date: Mon, 27 Feb 2023 10:45:44 +0000 Subject: [PATCH] [FIX] account: the comparison of the previous bank statement's closing balance vs the current bank statements opening balance is not rounded which might cause statements to be invalid closes odoo/odoo#113844 X-original-commit: 693649f7a611478d620f8c5d67549abb5bd1ca5e Signed-off-by: Laurent Smet --- addons/account/models/account_bank_statement.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index 939ddb3bc24..6cfcdfd4783 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -232,8 +232,11 @@ class AccountBankStatement(models.Model): self.env['account.bank.statement'].flush_model(['balance_start', 'balance_end_real', 'first_line_index']) self.env.cr.execute(f""" - SELECT id - FROM account_bank_statement st, + SELECT st.id + FROM account_bank_statement st + LEFT JOIN res_company co ON st.company_id = co.id + LEFT JOIN account_journal j ON st.journal_id = j.id + LEFT JOIN res_currency currency ON COALESCE(j.currency_id, co.currency_id) = currency.id, LATERAL ( SELECT balance_end_real FROM account_bank_statement st_lookup @@ -242,7 +245,7 @@ class AccountBankStatement(models.Model): ORDER BY st_lookup.first_line_index desc LIMIT 1 ) prev - WHERE prev.balance_end_real != st.balance_start + WHERE ROUND(prev.balance_end_real, currency.decimal_places) != ROUND(st.balance_start, currency.decimal_places) {"" if all_statements else "AND st.id IN %(ids)s"} """, { 'ids': tuple(self.ids)