Nehal Panchal (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-578283-nep into 
lp:openobject-addons/6.1.

Requested reviews:
  Naresh(OpenERP) (nch-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-578283-nep/+merge/121572

Hello, 

If we specify emails in CC of an automated action, emails are set in <To> 
instead of <CC> of a message.

To reproduce the problem:
1. Create an automated action and specify Cc in "Email Actions" tab.
2. Specified emails are set in <To> instead of <CC> of a message while 
executing an automated action.

This fixes the issue.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-578283-nep/+merge/121572
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-578283-nep.
=== modified file 'base_action_rule/base_action_rule.py'
--- base_action_rule/base_action_rule.py	2012-04-26 08:03:00 +0000
+++ base_action_rule/base_action_rule.py	2012-08-28 10:02:19 +0000
@@ -301,7 +301,7 @@
         }
         return self.format_body(body % data)
 
-    def email_send(self, cr, uid, obj, emails, body, emailfrom=None, context=None):
+    def email_send(self, cr, uid, obj, emails, body, email_cc=None, emailfrom=None, context=None):
         """ send email
             @param self: The object pointer
             @param cr: the current row, from the database cursor,
@@ -328,7 +328,7 @@
         if not emailfrom:
             raise osv.except_osv(_('Error!'),
                     _("No E-Mail ID Found for your Company address!"))
-        return mail_message.schedule_with_attach(cr, uid, emailfrom, emails, name, body, model='base.action.rule', reply_to=reply_to, res_id=obj.id)
+        return mail_message.schedule_with_attach(cr, uid, emailfrom, emails, name, body, model='base.action.rule', email_cc=email_cc, reply_to=reply_to, res_id=obj.id)
 
 
     def do_check(self, cr, uid, action, obj, context=None):
@@ -417,12 +417,14 @@
             getattr(model_obj, 'act_method')(cr, uid, [obj.id], action, context)
 
         emails = []
+        email_cc = []
         if hasattr(obj, 'user_id') and action.act_mail_to_user:
             if obj.user_id:
                 emails.append(obj.user_id.user_email)
 
         if action.act_mail_to_watchers:
-            emails += (action.act_email_cc or '').split(',')
+            email_cc += (action.act_email_cc or '').split(',')
+            email_cc = list(set(email_cc))
         if action.act_mail_to_email:
             emails += (action.act_mail_to_email or '').split(',')
 
@@ -444,7 +446,7 @@
             emails = to_email(','.join(filter(None, emails)))
             email_froms = to_email(email_from)
             if email_froms:
-                self.email_send(cr, uid, obj, emails, action.act_mail_body, emailfrom=email_froms[0])
+                self.email_send(cr, uid, obj, emails, action.act_mail_body, email_cc=email_cc, emailfrom=email_froms[0])
         return True
 
     def _action(self, cr, uid, ids, objects, scrit=None, context=None):

=== modified file 'crm/crm_action_rule.py'
--- crm/crm_action_rule.py	2012-08-28 07:41:39 +0000
+++ crm/crm_action_rule.py	2012-08-28 10:02:19 +0000
@@ -45,7 +45,7 @@
                                               help="Check this if you want the rule to send an email to the partner."),
     }
 
-    def email_send(self, cr, uid, obj, emails, body, emailfrom=tools.config.get('email_from', False), context=None):
+    def email_send(self, cr, uid, obj, emails, body, email_cc=None, emailfrom=tools.config.get('email_from', False), context=None):
         mail_message = self.pool.get('mail.message')
         body = self.format_mail(obj, body)
         if not emailfrom:
@@ -60,7 +60,9 @@
             reply_to = emailfrom
         if not emailfrom:
             raise osv.except_osv(_('Error!'), _("No E-Mail Found for your Company address!"))
-        return mail_message.schedule_with_attach(cr, uid, emailfrom, emails, name, body, model=obj._name, reply_to=reply_to, res_id=obj.id)
+        if '@' in (obj.email_cc or ''):
+            email_cc += obj.email_cc.split(',')
+        return mail_message.schedule_with_attach(cr, uid, emailfrom, emails, name, body, model=obj._name, email_cc=email_cc, reply_to=reply_to, res_id=obj.id)
 
     def do_check(self, cr, uid, action, obj, context=None):
         ok = super(base_action_rule, self).do_check(cr, uid, action, obj, context=context)

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to