From 9224313e344bb022c0fa4a2d88b0c3915b76ad35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 22 Dec 2021 09:27:00 +0000 Subject: [PATCH] [IMP] account: search on parent_state instead of move_id.state By searching on account.move.line parent_state instead of move_id.state, we avoid a join in many circumstances and allow the database to benefit on an index on company_id+parent_state to optimize several queries, such as the default filter on the Journal Items menu which shows posted items. closes odoo/odoo#82504 X-original-commit: ef61db1cf8ebf1ab11e5dfdd439256d0607edba8 Signed-off-by: Quentin De Paoli Signed-off-by: Florian Gilbert --- addons/account/models/account_journal_dashboard.py | 4 ++-- addons/account/views/account_move_views.xml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py index e73435fb36e..bdf6aeb065b 100644 --- a/addons/account/models/account_journal_dashboard.py +++ b/addons/account/models/account_journal_dashboard.py @@ -245,9 +245,9 @@ class account_journal(models.Model): last_balance = last_statement.balance_end has_at_least_one_statement = bool(last_statement) bank_account_balance, nb_lines_bank_account_balance = self._get_journal_bank_account_balance( - domain=[('move_id.state', '=', 'posted')]) + domain=[('parent_state', '=', 'posted')]) outstanding_pay_account_balance, nb_lines_outstanding_pay_account_balance = self._get_journal_outstanding_payments_account_balance( - domain=[('move_id.state', '=', 'posted')]) + domain=[('parent_state', '=', 'posted')]) self._cr.execute(''' SELECT COUNT(st_line.id) diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index d024fff2d8a..8801b96dbe7 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -349,8 +349,8 @@ - - + + @@ -1456,7 +1456,7 @@ {'journal_type':'general', 'search_default_posted':1} Journal Items account.move.line - [('display_type', 'not in', ('line_section', 'line_note'))] + [('display_type', 'not in', ('line_section', 'line_note')), ('parent_state', '!=', 'cancel')] tree,pivot,graph,form,kanban