diff options
| author | Julien (juc) Castiaux <juc@odoo.com> | 2019-01-14 12:55:27 +0000 |
|---|---|---|
| committer | Julien (juc) Castiaux <juc@odoo.com> | 2019-01-17 15:19:54 +0000 |
| commit | 71c4c13996d72243b9e5a063ebb416f74ea790cd (patch) | |
| tree | 3728a906925105ce38ebf820c9a9c3103572dd9b /addons/web_editor/controllers/main.py | |
| parent | ba41c3c1cccfdd7d9e499f426db669bc8efea4e6 (diff) | |
[FIX] web_editor: save less file
Modifying less files and saving them using the web editor can raise
and error. The error is due to the way odoo save the modified file.
It extends the view containing the URL of the file by filtering views
related to the xml bundle id and keeping those that have the said URL
in their content.
This lookup fails to give just one result in case there are multiple
file containing the said URL. This fix change the filter from a
bare `if url in view.arch` to a correct xpath lookup.
The "/web/static/src/variables.less" less file was one of the
problematic files.
opw-1889794
closes odoo/odoo#30186
Diffstat (limited to 'addons/web_editor/controllers/main.py')
| -rw-r--r-- | addons/web_editor/controllers/main.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index 3a156f69be7..3efadce2ba4 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -380,7 +380,17 @@ class Web_Editor(http.Controller): # Create a view to extend the template which adds the original file to link the new modified version instead IrUiView = request.env["ir.ui.view"] - view_to_xpath = IrUiView.get_related_views(bundle_xmlid, bundles=True).filtered(lambda v: v.arch.find(url) >= 0) + + def views_linking_url(view): + """ + Returns whether the view arch has some html link tag linked to the url. + + (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))) + + view_to_xpath = IrUiView.get_related_views(bundle_xmlid, bundles=True).filtered(views_linking_url) + IrUiView.create(dict( name = custom_url, mode = "extension", |
