← Back to team overview

openerp-india team mailing list archive

[Bug 1040501] [NEW] email_template: active model in send_mail method

 

Public bug reported:

Hello,

there is a problem in the send_email method of the 'mail.compose.message' object.
In some cases if you switch the template of the email the context['active_model'] is 'mail.compose.message' and not the model of the object where you call the email wizard from.
This is a problem for the method call of render_template.

To fix it you can use the context['mail.compose.target.id'] instead of the context['active_ids']
and context['mail.compose.target.model'] instead of context['active_model'].

I use the OpenERP 6.1 Trunk.

Regards,
Yasin Zschiesche


--- mail_compose_message.py     2012-08-23 10:41:23.950723595 +0200
+++ mail_compose_message.py    2012-08-23 10:41:18.318723729 +0200
@@ -214,7 +214,11 @@
                     active_model = mail.model
                     active_model_pool = self.pool.get(active_model)
                     active_ids = active_model_pool.search(cr, uid, ast.literal_eval(mail.filter_id.domain), context=ast.literal_eval(mail.filter_id.context))
-
+                
+                if 'mail.compose.target.id' in context:
+                    active_ids = [context['mail.compose.target.id']]
+                if 'mail.compose.target.model' in context['mail.compose.target.model']:
+                    active_model = context['mail.compose.target.model']
                 for active_id in active_ids:
                     subject = self.render_template(cr, uid, mail.subject, active_model, active_id)
                     rendered_body = self.render_template(cr, uid, body, active_model, active_id)

** Affects: openobject-addons
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1040501

Title:
  email_template: active model in send_mail method

Status in OpenERP Addons (modules):
  New

Bug description:
  Hello,

  there is a problem in the send_email method of the 'mail.compose.message' object.
  In some cases if you switch the template of the email the context['active_model'] is 'mail.compose.message' and not the model of the object where you call the email wizard from.
  This is a problem for the method call of render_template.

  To fix it you can use the context['mail.compose.target.id'] instead of the context['active_ids']
  and context['mail.compose.target.model'] instead of context['active_model'].

  I use the OpenERP 6.1 Trunk.

  Regards,
  Yasin Zschiesche

  
  --- mail_compose_message.py     2012-08-23 10:41:23.950723595 +0200
  +++ mail_compose_message.py    2012-08-23 10:41:18.318723729 +0200
  @@ -214,7 +214,11 @@
                       active_model = mail.model
                       active_model_pool = self.pool.get(active_model)
                       active_ids = active_model_pool.search(cr, uid, ast.literal_eval(mail.filter_id.domain), context=ast.literal_eval(mail.filter_id.context))
  -
  +                
  +                if 'mail.compose.target.id' in context:
  +                    active_ids = [context['mail.compose.target.id']]
  +                if 'mail.compose.target.model' in context['mail.compose.target.model']:
  +                    active_model = context['mail.compose.target.model']
                   for active_id in active_ids:
                       subject = self.render_template(cr, uid, mail.subject, active_model, active_id)
                       rendered_body = self.render_template(cr, uid, body, active_model, active_id)

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1040501/+subscriptions


Follow ups

References