[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
This commit is contained in:
Romain Derie
2021-07-30 13:51:25 +00:00
committed by Jeremy Kersten
parent 3416c596d9
commit 59098dbc60
+6 -5
View File
@@ -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):