From 1cde02457b34ace104ffa0f92d622611cf309674 Mon Sep 17 00:00:00 2001 From: william-andre Date: Wed, 18 Jan 2023 18:13:40 +0000 Subject: [PATCH] [FIX] account: performance of account selector side bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding a domain on the accounts before doing the lateral join helps reducing the amount of lateral queries needed to be done, most of which would return an empty subset. Since an empty subset on a query with limit=1 means that we need to scan the whole table, it can have a huge impact. closes odoo/odoo#111415 X-original-commit: 10a5e494aa5f9328e97052289ac829aad5f80c86 Signed-off-by: Fabien Pinckaers Signed-off-by: William André (wan) --- addons/account/models/account_move_line.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index 7f06b750997..0a6fe00d8ec 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -1567,7 +1567,8 @@ class AccountMoveLine(models.Model): SELECT account.root_id FROM account_account account, LATERAL ({query_str}) line - """, query_param) + WHERE account.company_id IN %s + """, query_param + [tuple(self.env.companies.ids)]) return { root.id: {'id': root.id, 'display_name': root.display_name} for root in self.env['account.root'].browse(id for [id] in self.env.cr.fetchall())