[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:
parent
e26bfd9d13
commit
a9e3d74713
|
@ -423,7 +423,7 @@ class google_calendar(osv.AbstractModel):
|
||||||
if type == "write":
|
if type == "write":
|
||||||
for oe_attendee in event['attendee_ids']:
|
for oe_attendee in event['attendee_ids']:
|
||||||
if oe_attendee.email == google_attendee['email']:
|
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
|
google_attendee['found'] = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -442,6 +442,7 @@ class google_calendar(osv.AbstractModel):
|
||||||
partner_record.append((4, attendee.get('id')))
|
partner_record.append((4, attendee.get('id')))
|
||||||
attendee['partner_id'] = attendee.pop('id')
|
attendee['partner_id'] = attendee.pop('id')
|
||||||
attendee['state'] = google_attendee['responseStatus']
|
attendee['state'] = google_attendee['responseStatus']
|
||||||
|
attendee['google_internal_event_id'] = single_event_dict.get('id')
|
||||||
attendee_record.append((0, 0, attendee))
|
attendee_record.append((0, 0, attendee))
|
||||||
for google_alarm in single_event_dict.get('reminders', {}).get('overrides', []):
|
for google_alarm in single_event_dict.get('reminders', {}).get('overrides', []):
|
||||||
alarm_id = calendar_alarm_obj.search(
|
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")
|
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})
|
ev_obj.write(cr, uid, att.event_id.id, {'oe_update_date': update_date})
|
||||||
new_ids.append(response['id'])
|
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()
|
cr.commit()
|
||||||
else:
|
else:
|
||||||
_logger.warning("Impossible to create event %s. [%s]" % (att.event_id.id, st))
|
_logger.warning("Impossible to create event %s. [%s]" % (att.event_id.id, st))
|
||||||
|
|
Loading…
Reference in New Issue