[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 <las@odoo.com>
Signed-off-by: Julien Van Roy <juvr@odoo.com>
This commit is contained in:
Julien Van Roy
2023-03-17 20:21:22 +01:00
parent 7718f12c8b
commit d8890195db
@@ -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