From 9ba569874c494fa2065d1fa2ec79a79e4cf09d00 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 28 Sep 2016 12:39:55 +0200 Subject: [PATCH] [FIX] calendar: fix attendees list in invitation email Upon the creation of an event, the list of attendees displayed in the invitation emails were not complete because the emails were sent as the attendees were being added to the event, in the loop. e.g.: - Create an event with Joseph and Michel - Joseph received the invitation email with only him as attendee - Michel received the invitaiton email with Joseph and him. The invitation email of Joseph now contains all the attendees. opw-681242 --- addons/calendar/calendar.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py index 85dc1035b3f..5ed50a207a9 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -1063,6 +1063,7 @@ class calendar_event(osv.Model): attendees[att.partner_id.id] = True new_attendees = [] new_att_partner_ids = [] + attendees_to_mail = [] for partner in event.partner_ids: if partner.id in attendees: continue @@ -1084,8 +1085,7 @@ class calendar_event(osv.Model): if not current_user.email or current_user.email != partner.email: mail_from = current_user.email or tools.config.get('email_from', False) if not context.get('no_email'): - if self.pool['calendar.attendee']._send_mail_to_attendees(cr, uid, att_id, email_from=mail_from, context=context): - self.message_post(cr, uid, event.id, body=_("An invitation email has been sent to attendee %s") % (partner.name,), subtype="calendar.subtype_invitation", context=context) + attendees_to_mail.append((att_id, mail_from, partner.name)) if new_attendees: self.write(cr, uid, [event.id], {'attendee_ids': [(4, att) for att in new_attendees]}, context=context) @@ -1105,6 +1105,10 @@ class calendar_event(osv.Model): if attendee_ids_to_remove: self.pool['calendar.attendee'].unlink(cr, uid, attendee_ids_to_remove, context) + for att_id, mail_from, partner_name in attendees_to_mail: + if self.pool['calendar.attendee']._send_mail_to_attendees(cr, uid, att_id, email_from=mail_from, context=context): + self.message_post(cr, uid, event.id, body=_("An invitation email has been sent to attendee %s") % (partner_name,), subtype="calendar.subtype_invitation", context=context) + res[event.id] = { 'new_attendee_ids': new_attendees, 'old_attendee_ids': all_attendee_ids,