[FIX] base_calendar: meetings email notification recipients
authorEddy Ernesto del Valle Pino <eddy@merchise.org>
Thu, 20 Nov 2014 18:38:40 +0000 (13:38 -0500)
committerMartin Trigaux <mat@odoo.com>
Mon, 1 Dec 2014 13:53:13 +0000 (14:53 +0100)
Reminder emails are generated based on the list of attendees.
The email_to field used to be a string with a list of emails separated by spaces
while the comma is the valid separator (RFC2822).
Fixes #3933 #3784 #2033

addons/base_calendar/base_calendar.py

index 0f7ef0c..64053bb 100644 (file)
@@ -839,8 +839,7 @@ class calendar_alarm(osv.osv):
         current_datetime = datetime.now()
         alarm_ids = self.search(cr, uid, [('state', '!=', 'done')], context=context)
 
-        mail_to = ""
-
+        mail_to = set()
         for alarm in self.browse(cr, uid, alarm_ids, context=context):
             next_trigger_date = None
             update_vals = {}
@@ -890,10 +889,12 @@ From:
 </pre>
 """  % (alarm.name, alarm.trigger_date, alarm.description, \
                         alarm.user_id.name, alarm.user_id.signature)
-                    mail_to = alarm.user_id.email
+                    mail_to.add(alarm.user_id.email)
                     for att in alarm.attendee_ids:
-                        mail_to = mail_to + " " + att.user_id.email
+                        if att.user_id.email:
+                            mail_to.add(att.user_id.email)
                     if mail_to:
+                        mail_to = ','.join(mail_to)
                         vals = {
                             'state': 'outgoing',
                             'subject': sub,
@@ -1121,7 +1122,7 @@ rule or repeating pattern of time to exclude from the recurring rule."),
             for att in event.attendee_ids:
                 attendees[att.partner_id.id] = True
             new_attendees = []
-            mail_to = ""
+            mail_to = set()
             for partner in event.partner_ids:
                 if partner.id in attendees:
                     continue
@@ -1134,13 +1135,14 @@ rule or repeating pattern of time to exclude from the recurring rule."),
                     'email': partner.email
                 }, context=local_context)
                 if partner.email:
-                    mail_to = mail_to + " " + partner.email
+                    mail_to.add(partner.email)
                 self.write(cr, uid, [event.id], {
                     'attendee_ids': [(4, att_id)]
                 }, context=context)
                 new_attendees.append(att_id)
 
             if mail_to and current_user.email:
+                mail_to = ','.join(mail_to)
                 att_obj._send_mail(cr, uid, new_attendees, mail_to,
                     email_from = current_user.email, context=context)
         return True