diff options
| author | Romain Derie <rde@odoo.com> | 2019-01-25 10:35:22 +0000 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2019-01-29 16:06:23 +0000 |
| commit | 326a44c3f7f754160c78649f7c6c69dc0c030d92 (patch) | |
| tree | 1c9b8221aacaf32a3aaf1bcb73c12732f00d981e /addons/web_editor/controllers/main.py | |
| parent | 751ea9634a690bb1642be6d66d4124d6311766c7 (diff) | |
[FIX] web_editor, website: consider COW view when loading view
Before this commit:
1. If we were editing a template with no xml_id, typically the case when
editing a specific view (COW'd), the 'Template ID' label would be left empty
as the view does not have an xml_id but only a key.
2. If we were editing a generic view, the template would be COW'd and replaced
by the specific one created during the save.
After the save, the page would be reload and will try to reopen the edited
template (stored in url `res=123`). But as this template would be replaced
by the COW'd view, the JS would crash trying to access an inexisting view.
The HTML editor would then open in a very thin modal, barely editable.
Now:
1. Display the template's key instead of its xml_id. The key is basically a
duplicate of the xml_id, mainly used in website.
2. If we are saving a generic view, we search for its newly created specific
view to upload the URL hash before reloading.
task-1934279
Fix #30447
Diffstat (limited to 'addons/web_editor/controllers/main.py')
| -rw-r--r-- | addons/web_editor/controllers/main.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index 5c7b5316d44..d6d39817d7f 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -271,6 +271,9 @@ class Web_Editor(http.Controller): result['originalSrc'] = record.url return result + def _get_view_fields_to_read(self): + return ['name', 'id', 'key', 'xml_id', 'arch', 'active', 'inherit_id'] + ## The get_assets_editor_resources route is in charge of transmitting the resources the assets ## editor needs to work. ## @param key - the xml_id or id of the view the resources are related to @@ -283,7 +286,7 @@ class Web_Editor(http.Controller): def get_assets_editor_resources(self, key, get_views=True, get_scss=True, bundles=False, bundles_restriction=[]): # Related views must be fetched if the user wants the views and/or the style views = request.env["ir.ui.view"].get_related_views(key, bundles=bundles) - views = views.read(['name', 'id', 'key', 'xml_id', 'arch', 'active', 'inherit_id']) + views = views.read(self._get_view_fields_to_read()) scss_files_data_by_bundle = [] |
