Use Text field for HTML content of report record
The field must contain strings in order to allow edition with the HTML editor. Closes #14922 (grafted from 73b5636cf6abe1ea23f05bab04772129a5178e11) --HG-- branch : 7.0
This commit is contained in:
1 parent
880c08fc7f
commit
520ff2bf96
1 file changed
+10
-3
@@ -484,7 +484,7 @@ class ActionReport(ActionMixin, ModelSQL, ModelView):
|
||||
'get_report_content', setter='set_report_content')
|
||||
report_content_name = fields.Function(fields.Char('Content Name'),
|
||||
'on_change_with_report_content_name')
|
||||
report_content_html = fields.Function(fields.Binary(
|
||||
report_content_html = fields.Function(fields.Text(
|
||||
"Content HTML",
|
||||
states={
|
||||
'invisible': ~Eval('template_extension').in_(
|
||||
@@ -646,11 +646,18 @@ class ActionReport(ActionMixin, ModelSQL, ModelView):
|
||||
|
||||
@classmethod
|
||||
def get_report_content_html(cls, reports, name):
|
||||
return cls.get_report_content(reports, name[:-5])
|
||||
contents = cls.get_report_content(reports, name[:-5])
|
||||
for report_id, content in contents.items():
|
||||
if isinstance(content, bytes):
|
||||
try:
|
||||
contents[report_id] = content.decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
return contents
|
||||
|
||||
@classmethod
|
||||
def set_report_content_html(cls, reports, name, value):
|
||||
if value is not None:
|
||||
if isinstance(value, str):
|
||||
value = value.encode('utf-8')
|
||||
cls.set_report_content(reports, name[:-5], value)
|
||||
|
||||
|
||||
Reference in new issue
Block a user