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)
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