Skip to content
Permalink
Browse files

[FIX] google_calendar: exclusions not propagating (from OE)

Activate Google Synchronization, create on OE a recurrent event,
synchronize the calendar, then delete an event of the recursion on GC,
sync again on OE.

The event will be deleted from GC but not from OE after sync.

This appens because of this "rewrite" rule
https://github.com/odoo/odoo/blob/12.0/addons/calendar/models/calendar.py#L918
that occur on event creation from OE, altering the event parameters when
is marked "allday".

When an "allday" event is deleted from GC the unlink is triggered in OE with the
default time "00:00:00". During the creation of the exclusion '
_inverse_dates' will be called altering start and stop datetime but not
recurrent_id_date, so the new record will not match the event generating
the recursion and the exclusion will not occur. The problem require
particular carefulness because when a recurrent event is fetched from
google the '_inverse_dates' is not called, so in that case the default
time is fine.

opw-2060526

closes #39649

X-original-commit: a468464
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
  • Loading branch information...
agr-odoo authored and fw-bot committed Oct 30, 2019
1 parent 7f630bf commit ada2f7470760275b02c037b607d190e949136b05
Showing with 8 additions and 4 deletions.
  1. +8 −4 addons/google_calendar/models/google_calendar.py
@@ -831,10 +831,15 @@ def update_events(self, lastSync=False):
recs.delete_an_event(current_event[0])
elif actSrc == 'GG':
new_google_event_id = event.GG.event['id'].rsplit('_', 1)[1]
parent_oe = event_to_synchronize[base_event][0][1].OE.event
if 'T' in new_google_event_id:
new_google_event_id = new_google_event_id.replace('T', '')[:-1]
else:
new_google_event_id = new_google_event_id + "000000"
#allday event, need to match the changes that will be applied with _inverse_dates otherwise the exclusion will not occur
if parent_oe:
new_google_event_id = new_google_event_id + parent_oe.start.strftime("%H%M%S")
else:
new_google_event_id = new_google_event_id + "000000"

if event.GG.status:
parent_event = {}
@@ -848,9 +853,8 @@ def update_events(self, lastSync=False):
else:
recs.create_from_google(event, my_partner_id)
else:
parent_oe_id = event_to_synchronize[base_event][0][1].OE.event_id
if parent_oe_id:
CalendarEvent.browse("%s-%s" % (parent_oe_id, new_google_event_id)).with_context(curr_attendee=event.OE.attendee_id).unlink(can_be_deleted=True)
if parent_oe:
CalendarEvent.browse("%s-%s" % (parent_oe.id, new_google_event_id)).with_context(curr_attendee=event.OE.attendee_id).unlink(can_be_deleted=True)
else:
main_att = CalendarAttendee.with_context(context_novirtual).search([('partner_id', '=', my_partner_id), ('google_internal_event_id', '=', event.GG.event['id'].rsplit('_', 1)[0])], limit=1)
if main_att:

0 comments on commit ada2f74

Please sign in to comment.
You can’t perform that action at this time.