From 8d64d9fabcfce5798872cb50a87a9b78983ec280 Mon Sep 17 00:00:00 2001 From: Xavier ALT Date: Mon, 20 Aug 2012 09:56:41 +0200 Subject: [PATCH] [FIX] email_template: when composing email on unique resource force non mass_mail mode bzr revid: xal@openerp.com-20120820075641-0cqi0r5jkgz0dd02 --- .../email_template/wizard/mail_compose_message.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 90e5202f7f0..1543d9ec62b 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -82,7 +82,10 @@ class mail_compose_message(osv.osv_memory): values = {} if template_id: res_id = context.get('mail.compose.target.id') or context.get('active_id') or False - if context.get('mail.compose.message.mode') == 'mass_mail': + # when composing message interactivly, do not use mass_mail mode if user are working + # on a unique resource (ex: when composing message from a form view) + working_on_multi_resources = len(context.get('active_ids') or []) > 1 and True or False + if context.get('mail.compose.message.mode') == 'mass_mail' and working_on_multi_resources: # use the original template values - to be rendered when actually sent # by super.send_mail() values = self.pool.get('email.template').read(cr, uid, template_id, self.fields_get_keys(cr, uid), context) @@ -91,14 +94,6 @@ class mail_compose_message(osv.osv_memory): values['attachments'] = False attachments = {} - if len(context.get('active_ids')) == 1: - values['email_from'] = self.render_template(cr, uid, template.email_from, template.model, res_id, context) - values['email_to'] = self.render_template(cr, uid, template.email_to, template.model, res_id, context) - values['email_cc'] = self.render_template(cr, uid, template.email_cc, template.model, res_id, context) - values['email_bcc'] = self.render_template(cr, uid, template.email_bcc, template.model, res_id, context) - values['reply_to'] = self.render_template(cr, uid, template.reply_to, template.model, res_id, context) - values['subject'] = self.render_template(cr, uid, template.subject, template.model, res_id, context) - values['body_text'] = self.render_template(cr, uid, template.body_text, template.model, res_id, context) or '' if template.report_template: report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=context) report_service = 'report.' + report_xml_pool.browse(cr, uid, template.report_template.id, context).report_name