[FIX] account: Fix Journal Dashboard Running balance query

On Database having a postgresql server version superior or
equals than 14.0, a feature called memoization is caching
result of the lateral join made in this query.
This cache creates an issue that results that customers
have the same result for their bank journals.

By adding a LIMIT 1 at the end of the lateral join query,
the memoization is not enabled (according to query plan).
Another solution could be to change the condition of this
lateral join (currently ON True) for a condition on the
journal id but it was less efficient.

opw-3422495

closes odoo/odoo#136498

X-original-commit: 0ccdd9344e2192049aa196f419abac7eb59e4f1a
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
This commit is contained in:
Florian(flg)
2023-09-26 07:12:55 +00:00
parent 1f206910b5
commit b3d68e95ab
@@ -583,6 +583,7 @@ class account_journal(models.Model):
AND move.state != 'cancel'
AND move.journal_id = journal.id
AND stl.internal_index >= COALESCE(statement.first_line_index, '')
LIMIT 1
) without_statement ON TRUE
WHERE journal.id = ANY(%s)
""", [(self.ids)])