From d8890195db110f964451966076723e680f426f93 Mon Sep 17 00:00:00 2001 From: Julien Van Roy Date: Fri, 10 Mar 2023 15:17:44 +0000 Subject: [PATCH] [FIX] account: fix join bank statement lines and move In some databases, there are multiple bank statement lines linked to the same move. Example: * account_move: id | statement_line_id ---+------------------ 5 | 20 * bank_statement_line: id | move_id -----+-------- 20 | 5 21 | 5 Thus, joining both tables should be done using the account_move.id and the bank_statement_line.move_id. Otherwise, some bank_statement_lines will be missed. opw-3202392 closes odoo/odoo#115687 X-original-commit: c63cdde8506e201bf3313c5566049dde6692d0a6 Related: odoo/enterprise#38338 Signed-off-by: Laurent Smet Signed-off-by: Julien Van Roy --- addons/account/models/account_bank_statement_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_bank_statement_line.py b/addons/account/models/account_bank_statement_line.py index 56a998234d3..dc9fcb1ce5f 100644 --- a/addons/account/models/account_bank_statement_line.py +++ b/addons/account/models/account_bank_statement_line.py @@ -199,7 +199,7 @@ class AccountBankStatementLine(models.Model): COALESCE(st.balance_start, 0.0), move.state FROM account_bank_statement_line st_line - JOIN account_move move ON move.statement_line_id = st_line.id + JOIN account_move move ON move.id = st_line.move_id LEFT JOIN account_bank_statement st ON st.id = st_line.statement_id WHERE st_line.internal_index <= %s