[FIX] google_calendar: event duplication during sync to google

With User A <a@gmail.com> and user B <b@gmail.com> both syncing
their calendar with Google.
If User a created an event X, adding as attendee himself and user B,
and then synced his calendar to Google, a new event was
created in User B Google Agenda automatically, representing the
invitation.
At this stage, X appears only once, in the four calendars
(Odoo cal for A, Odoo cal for B, Google Cal for A, Google Cal for B)

If user B then synced his calendar to Odoo, the event X was
duplicated in three of the calendars (Odoo cal for A and B, Google cal for B)

If then user A synced again his calendar with Google, the event X
was duplicated in the four calendars.

From then, a duplicate loop began, at each sync of the both user calendars.

opw-639419
This commit is contained in:
Denis Ledoux 2015-06-01 18:14:50 +02:00
parent e26bfd9d13
commit a9e3d74713
1 changed files with 3 additions and 2 deletions

View File

@ -423,7 +423,7 @@ class google_calendar(osv.AbstractModel):
if type == "write":
for oe_attendee in event['attendee_ids']:
if oe_attendee.email == google_attendee['email']:
calendar_attendee_obj.write(cr, uid, [oe_attendee.id], {'state': google_attendee['responseStatus']}, context=context)
calendar_attendee_obj.write(cr, uid, [oe_attendee.id], {'state': google_attendee['responseStatus'], 'google_internal_event_id': single_event_dict.get('id')}, context=context)
google_attendee['found'] = True
continue
@ -442,6 +442,7 @@ class google_calendar(osv.AbstractModel):
partner_record.append((4, attendee.get('id')))
attendee['partner_id'] = attendee.pop('id')
attendee['state'] = google_attendee['responseStatus']
attendee['google_internal_event_id'] = single_event_dict.get('id')
attendee_record.append((0, 0, attendee))
for google_alarm in single_event_dict.get('reminders', {}).get('overrides', []):
alarm_id = calendar_alarm_obj.search(
@ -626,7 +627,7 @@ class google_calendar(osv.AbstractModel):
update_date = datetime.strptime(response['updated'], "%Y-%m-%dT%H:%M:%S.%fz")
ev_obj.write(cr, uid, att.event_id.id, {'oe_update_date': update_date})
new_ids.append(response['id'])
att_obj.write(cr, uid, [att.id], {'google_internal_event_id': response['id'], 'oe_synchro_date': update_date})
att_obj.write(cr, uid, [att.id for att in att.event_id.attendee_ids], {'google_internal_event_id': response['id'], 'oe_synchro_date': update_date})
cr.commit()
else:
_logger.warning("Impossible to create event %s. [%s]" % (att.event_id.id, st))