[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.
This commit is contained in:
Christophe Simonis
2016-07-13 19:19:11 +02:00
parent 9b77d76e71
commit 7930c3f86e
+8 -4
View File
@@ -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()