diff options
| author | qsm-odoo <qsm@odoo.com> | 2018-06-20 13:14:17 +0200 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2018-06-20 13:18:16 +0200 |
| commit | f01a0bc04c5e5fb3b21983ef24cf2849061a1695 (patch) | |
| tree | bbb3f47a305bbba0c189c03ae32c88033f23b4e5 /addons/web_editor/controllers | |
| parent | a53bea49fe4005e3faaa3e63888da65a45281dd5 (diff) | |
[FIX] web_editor: allow to empty a style file with the editor
Before this commit, if the user opened the LESS editor and emptied a
file, he may get a compilation error (as intended if the file contained
necessary variables and stuff) but this error also prevented to open
the editor again because some code tried to decode an empty content.
Now, when a file is emptied it is set to an unique line feed.
Diffstat (limited to 'addons/web_editor/controllers')
| -rw-r--r-- | addons/web_editor/controllers/main.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index 054850b0926..be4c9738c0a 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -352,16 +352,17 @@ class Web_Editor(http.Controller): # Check if the file to save had already been modified custom_attachment = IrAttachment.search([("url", "=", custom_url)]) + datas = (content or "\n").encode("utf-8").encode("base64") if custom_attachment: # If it was already modified, simply override the corresponding attachment content - custom_attachment.write({"datas": content.encode("utf-8").encode("base64")}) + custom_attachment.write({"datas": datas}) else: # If not, create a new attachment to copy the original LESS file content, with its modifications IrAttachment.create(dict( name = custom_url, type = "binary", mimetype = "text/less", - datas = content.encode("utf-8").encode("base64"), + datas = datas, datas_fname = url.split("/")[-1], url = custom_url, # Having an attachment of "binary" type with an non empty "url" field # is quite of an hack. This allows to fetch the "datas" field by adding |
