summaryrefslogtreecommitdiff
path: root/addons/web_editor/controllers/main.py
diff options
context:
space:
mode:
authorKishan Gajjar <kig@odoo.com>2018-11-20 10:42:45 +0000
committerqsm-odoo <qsm@odoo.com>2019-01-28 14:10:03 +0000
commitdaceeb5348745d22855fa12eeed40ba0e0f6f743 (patch)
tree893bcf30054e241d343684531769b538a1f5d5ec /addons/web_editor/controllers/main.py
parent201a1664b2db28baf32f3bf71d776f18d331daf7 (diff)
[FIX] web_editor: use default value for html fields of new records
While creating a new record, the default value of a field used with the 'html_frame' field widget was not used. Discovered with task-1903256 closes odoo/odoo#28838
Diffstat (limited to 'addons/web_editor/controllers/main.py')
-rw-r--r--addons/web_editor/controllers/main.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py
index 2a82e7276bf..126f25fc423 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)