[FIX] email_template: when composing email on unique resource force non mass_mail mode

bzr revid: xal@openerp.com-20120820075641-0cqi0r5jkgz0dd02
This commit is contained in:
Xavier ALT
2012-08-20 09:56:41 +02:00
parent 65ef848301
commit 8d64d9fabc
@@ -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