[IMP] base: bypass _inverse_arch() in view creation

By default, whatever is written on field 'arch' is handled by its
inverse method inverse_arch(), which writes on the low-level field
'arch_db'.  When writing on 'arch_db', the cache is cleared, which leads
to performance loss because the arch needs to be re-fetched.

This optimization bypasses the inverse method on view creation, this is
safe as there is nothing wrong in the cache and makes view creation 20%
faster, and installation 7% faster.
This commit is contained in:
Raphael Collet
2021-06-15 08:44:03 +00:00
committed by Julien Castiaux
parent d29c8427d1
commit ee8756b311
+10
View File
@@ -504,6 +504,16 @@ actual arch.
values['name'] = "%s %s" % (values.get('model'), values['type'])
# Create might be called with either `arch` (xml files), `arch_base` (form view) or `arch_db`.
values['arch_prev'] = values.get('arch_base') or values.get('arch_db') or values.get('arch')
# write on arch: bypass _inverse_arch()
if 'arch' in values:
values['arch_db'] = values.pop('arch')
if 'install_filename' in self._context:
# we store the relative path to the resource instead of the absolute path, if found
# (it will be missing e.g. when importing data-only modules using base_import_module)
path_info = get_resource_from_path(self._context['install_filename'])
if path_info:
values['arch_fs'] = '/'.join(path_info[0:2])
values['arch_updated'] = False
values.update(self._compute_defaults(values))
self.clear_caches()