[FIX] email_template: when composing email on unique resource force non mass_mail...
authorXavier ALT <xal@openerp.com>
Mon, 20 Aug 2012 07:56:41 +0000 (09:56 +0200)
committerXavier ALT <xal@openerp.com>
Mon, 20 Aug 2012 07:56:41 +0000 (09:56 +0200)
bzr revid: xal@openerp.com-20120820075641-0cqi0r5jkgz0dd02

addons/email_template/wizard/mail_compose_message.py

index 90e5202..1543d9e 100644 (file)
@@ -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