From d1a19bcb7f0f41b80f6df3afefb2753a2222d887 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 24 Jun 2015 17:06:17 +0200 Subject: [PATCH] [IMP] base: performances of view._check_xml View validation accounts for a fair cost of module installation, most of that is spent checking for view validity, and a significant fraction of *that* is spent reading the validated view from the DB. Turns out _check_xml requested *all* view fields even though it needed none of them save for the arch. Specifying fields to read_combined rather than fetching all fields seems to result in a ~30% speedup of _check_xml (under line_profiler). Most of the rest is spent fetching sub-views (in get_inheriting_view_arch), I don't know that it can be improved without hand-crafting a fairly complex SQL request. --- openerp/addons/base/ir/ir_ui_view.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/ir/ir_ui_view.py b/openerp/addons/base/ir/ir_ui_view.py index ea7b11c426d..341f1ad7119 100644 --- a/openerp/addons/base/ir/ir_ui_view.py +++ b/openerp/addons/base/ir/ir_ui_view.py @@ -203,7 +203,7 @@ class view(osv.osv): # Sanity checks: the view should not break anything upon rendering! # Any exception raised below will cause a transaction rollback. for view in self.browse(cr, uid, ids, context): - view_def = self.read_combined(cr, uid, view.id, None, context=context) + view_def = self.read_combined(cr, uid, view.id, ['arch'], context=context) view_arch_utf8 = view_def['arch'] if view.type != 'qweb': view_doc = etree.fromstring(view_arch_utf8) @@ -527,7 +527,7 @@ class view(osv.osv): # arch and model fields are always returned if fields: - fields = list(set(fields) | set(['arch', 'model'])) + fields = list({'arch', 'model'}.union(fields)) # read the view arch [view] = self.read(cr, uid, [root_id], fields=fields, context=context)