From 13f02f2c0a5bc6eaedd0a11a10d188d57f590091 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 29 Jun 2018 13:02:16 +0200 Subject: [PATCH] Revert "[FIX] mail: Render mail in the template language" This reverts commit 5a0dcd3c20902cfd4dcbdb8d2493b1852cc85d65. Same as 6ad6df59b5041b Was mistakly merged, should not be integrated into stable --- addons/mail/models/mail_template.py | 3 +-- addons/mail/wizard/mail_compose_message.py | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/addons/mail/models/mail_template.py b/addons/mail/models/mail_template.py index 9de0c9bbb8e..cc07b375204 100644 --- a/addons/mail/models/mail_template.py +++ b/addons/mail/models/mail_template.py @@ -484,11 +484,10 @@ class MailTemplate(models.Model): # templates: res_id -> template; template -> res_ids templates_to_res_ids = {} for res_id, template in res_ids_to_templates.iteritems(): - templates_to_res_ids.setdefault((template, template.env.context.get('lang')), []).append(res_id) + templates_to_res_ids.setdefault(template, []).append(res_id) results = dict() for template, template_res_ids in templates_to_res_ids.iteritems(): - template = template[0] Template = self.env['mail.template'] # generate fields value for all res_ids linked to the current template if template.lang: diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 64d3f2dfbf6..4bc958684f9 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -443,8 +443,8 @@ class MailComposer(models.TransientModel): multi_mode = False res_ids = [res_ids] - subjects = self.render_template(self.subject, self.model, res_ids) if not self.template_id else False - bodies = self.render_template(self.body, self.model, res_ids, post_process=True) if not self.template_id else False + subjects = self.render_template(self.subject, self.model, res_ids) + bodies = self.render_template(self.body, self.model, res_ids, post_process=True) emails_from = self.render_template(self.email_from, self.model, res_ids) replies_to = self.render_template(self.reply_to, self.model, res_ids) default_recipients = {} @@ -454,8 +454,8 @@ class MailComposer(models.TransientModel): results = dict.fromkeys(res_ids, False) for res_id in res_ids: results[res_id] = { - 'subject': subjects[res_id] if subjects else False, - 'body': bodies[res_id] if subjects else False, + 'subject': subjects[res_id], + 'body': bodies[res_id], 'email_from': emails_from[res_id], 'reply_to': replies_to[res_id], } @@ -465,7 +465,7 @@ class MailComposer(models.TransientModel): if self.template_id: template_values = self.generate_email_for_composer( self.template_id.id, res_ids, - fields=['subject', 'body_html', 'email_to', 'partner_to', 'email_cc', 'attachment_ids', 'mail_server_id']) + fields=['email_to', 'partner_to', 'email_cc', 'attachment_ids', 'mail_server_id']) else: template_values = {} @@ -475,8 +475,6 @@ class MailComposer(models.TransientModel): results[res_id].pop('partner_ids') results[res_id].pop('email_to') results[res_id].pop('email_cc') - results[res_id].pop('subject') - results[res_id].pop('body') # remove attachments from template values as they should not be rendered template_values[res_id].pop('attachment_ids', None) else: