From 59098dbc606ff359ad648707f32f1c0fc06c8dc8 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Thu, 29 Jul 2021 10:34:27 +0000 Subject: [PATCH] [FIX] website: avoid commit, reset env, reload registry for no reason Before this commit, if the configurator was applied without a module to install it would still go through `_button_immediate_function()` which does ``` self._cr.commit() api.Environment.reset() modules.registry.Registry.new(self._cr.dbname, update_module=True) ``` for no reason, even if `self` is an empty module recordset. This code is taking ~5 seconds. This flow will occur when you either: - Create a new website when selecting only page feature - Create a new website when some modules feature are already installed Community: https://github.com/odoo/odoo/pull/71993 Enterprise: https://github.com/odoo/enterprise/pull/18930 task-2518565 --- addons/website/models/website.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 9b7e0bf335a..6f9e26b7865 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -351,12 +351,13 @@ class Website(models.Model): result = self.env['website'].new_page(name=feature_id.name, add_menu=True, template=feature_id.page_view_id.key) pages_views[feature_id.iap_page_code] = result['view_id'] - modules.button_immediate_install() + if modules: + modules.button_immediate_install() + # Force to refresh env after install of modules + self._cr.commit() + api.Environment.reset() + self.env = api.Environment(modules._cr, modules._uid, modules._context) - # Force to refresh env after install of modules - self._cr.commit() - api.Environment.reset() - self.env = api.Environment(modules._cr, modules._uid, modules._context) return pages_views def configure_page(page_code, snippet_list, pages_views, cta_data):