[FIX] mail: internal subtypes with special characters

The fields options in the form are evaluated with
a `py_eval`, see:
https://github.com/odoo/odoo/blob/3c2e48423b4f9706216cada549d0a725f2dd07d2/addons/web/static/src/js/views/form_common.js#L664,
not as a JSON.

This was changed in October 2012, with rev.
c538db258a

Therefore, the field options must not be passed as a JSON, but
as a Python dict.

This had as side-effect to uncorrectly load the internal
subtypes for the "log a note" feature. For instance,
French translations with accents were displayed incorrectly.

opw-656409
This commit is contained in:
Denis Ledoux
2015-11-16 16:38:54 +01:00
parent 3c2e48423b
commit c2a6aeb244
+2 -2
View File
@@ -366,7 +366,7 @@ class MailThread(models.AbstractModel):
doc = etree.XML(res['arch'])
for node in doc.xpath("//field[@name='message_ids']"):
# the 'Log a note' button is employee only
options = json.loads(node.get('options', '{}'))
options = eval(node.get('options', '{}'))
is_employee = self.env.user.has_group('base.group_user')
options['display_log_button'] = is_employee
if is_employee:
@@ -379,7 +379,7 @@ class MailThread(models.AbstractModel):
# emoji list
options['emoji_list'] = self.env['mail.shortcode'].search([('shortcode_type', '=', 'image')]).read(['source', 'description', 'substitution'])
# save options on the node
node.set('options', json.dumps(options))
node.set('options', repr(options))
res['arch'] = etree.tostring(doc)
return res