From c2a6aeb244bd08fa5c03191f7e5b5922d6ce81a2 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 16 Nov 2015 16:33:31 +0100 Subject: [PATCH] [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. c538db258abdcaa25ff1442c9b4cd3f2bbdb9935 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 --- addons/mail/models/mail_thread.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index a6acbd12156..6e9efec571e 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -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