diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-01-31 16:59:58 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-01-31 16:59:58 +0100 |
| commit | f927c68ddbe4dccbdd0174019d6028d30b0d8058 (patch) | |
| tree | af24ebffe8241ee0c6ec9c911f2fe15f54237bcc /addons/web_editor/controllers/main.py | |
| parent | 24ba5ae276a7c25cdcd4d2db2e17e032cfa7e52a (diff) | |
| parent | cb8fefa8999bd0056c2191edbdbbb85918d221da (diff) | |
[MERGE] forward port branch 12.0 up to cb8fefa8999
Diffstat (limited to 'addons/web_editor/controllers/main.py')
| -rw-r--r-- | addons/web_editor/controllers/main.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index 40cf2aba5ef..2ad2730dc93 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -50,11 +50,16 @@ class Web_Editor(http.Controller): kwargs.update(trans) - record = None - if model and kwargs.get('res_id'): - record = request.env[model].with_context(trans).browse(kwargs.get('res_id')) + content = None + if model: + Model = request.env[model].with_context(trans) + if kwargs.get('res_id'): + record = Model.browse(kwargs.get('res_id')) + content = record and getattr(record, field) + else: + content = Model.default_get([field]).get(field) - kwargs.update(content=record and getattr(record, field) or "") + kwargs.update(content=content or '') return request.render(kwargs.get("template") or "web_editor.FieldTextHtml", kwargs, uid=request.uid) @@ -265,6 +270,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 @@ -277,7 +285,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 = [] @@ -423,7 +431,7 @@ class Web_Editor(http.Controller): (note: searching for the URL string is not enough as it could appear in a comment or an xpath expression.) """ - return bool(etree.XML(view.arch).xpath("link[@href='{}']".format(url))) + return bool(etree.XML(view.arch).xpath("//link[@href='{}']".format(url))) view_to_xpath = IrUiView.get_related_views(bundle_xmlid, bundles=True).filtered(views_linking_url) |
