From a9e3d74713b6882c64617345696ad326d75a4745 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 1 Jun 2015 18:14:50 +0200 Subject: [PATCH] [FIX] google_calendar: event duplication during sync to google With User A and user B 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 --- addons/google_calendar/google_calendar.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/google_calendar/google_calendar.py b/addons/google_calendar/google_calendar.py index 9a5a43c551c..f443f9b2904 100644 --- a/addons/google_calendar/google_calendar.py +++ b/addons/google_calendar/google_calendar.py @@ -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))