[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
This commit is contained in:
Denis Ledoux
2016-09-28 12:43:51 +02:00
parent 8469fe2eac
commit 9ba569874c
+6 -2
View File
@@ -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,