From 7930c3f86ebf079167437f314dcdb8851aa9e563 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 13 Jul 2016 19:19:11 +0200 Subject: [PATCH] [IMP] base: ir.ui.view inherit search during module update During module update, we should only consider views of already loaded modules. This filter is done by searching on xmlids of views. We should also search for explicit view ids (current module is not yet marked as loaded) However, by doing this `OR` condition, the generated query is not optimal and forbid postgresql to use the composite index `ir_model_data_model_res_id_index` on `ir_model_data` table. This is a performance issue for databases with a lot of ir_model_data rows. Use 2 quicker search() to avoid this problem. This only affect the module update. Normal view loading is unchanged. --- openerp/addons/base/ir/ir_ui_view.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/ir/ir_ui_view.py b/openerp/addons/base/ir/ir_ui_view.py index 843c5ad3400..0e2e38c6acd 100644 --- a/openerp/addons/base/ir/ir_ui_view.py +++ b/openerp/addons/base/ir/ir_ui_view.py @@ -386,6 +386,7 @@ actual arch. :rtype: list of tuples :return: [(view_arch,view_id), ...] """ + views = self.browse() user_groups = self.env.user.groups_id conditions = [ @@ -396,13 +397,16 @@ actual arch. ] if self.pool._init and not self._context.get('load_all_views'): # Module init currently in progress, only consider views from - # modules whose code is already loaded + # modules whose code is already loaded and explicitly asked views + check_view_ids = self._context.get('check_view_ids') + if check_view_ids: + views = self.search(conditions + [('id', 'in', check_view_ids)]) + conditions.extend([ - '|', ('model_ids.module', 'in', tuple(self.pool._init_modules)), - ('id', 'in', self._context.get('check_view_ids') or (0,)), ]) - views = self.search(conditions) + + views += self.search(conditions) return [(view.arch, view.id) for view in views.sudo()