[FIX] Google Calendar - Split the last underscore because Google uses sometimes '_' in their own google_id. Retrieve the parent event_id to exclude when the exlusion has been done in google

This commit is contained in:
Jeremy Kersten 2014-06-13 17:57:01 +02:00
parent 3f6245e85f
commit 0c627438cc
1 changed files with 8 additions and 4 deletions

View File

@ -530,7 +530,7 @@ class google_calendar(osv.AbstractModel):
for att in att_obj.browse(cr, uid, my_att_ids, context=context):
event = att.event_id
base_event_id = att.google_internal_event_id.split('_')[0]
base_event_id = att.google_internal_event_id.rsplit('_', 1)[0]
if base_event_id not in event_to_synchronize:
event_to_synchronize[base_event_id] = {}
@ -552,7 +552,7 @@ class google_calendar(osv.AbstractModel):
for event in all_event_from_google.values():
event_id = event.get('id')
base_event_id = event_id.split('_')[0]
base_event_id = event_id.rsplit('_', 1)[0]
if base_event_id not in event_to_synchronize:
event_to_synchronize[base_event_id] = {}
@ -615,7 +615,7 @@ class google_calendar(osv.AbstractModel):
if actSrc == 'OE':
self.delete_an_event(cr, uid, current_event[0], context=context)
elif actSrc == 'GG':
new_google_event_id = event.GG.event['id'].split('_')[1]
new_google_event_id = event.GG.event['id'].rsplit('_', 1)[1]
if 'T' in new_google_event_id:
new_google_event_id = new_google_event_id.replace('T', '')[:-1]
else:
@ -623,7 +623,11 @@ class google_calendar(osv.AbstractModel):
if event.GG.status:
parent_event = {}
parent_event['id'] = "%s-%s" % (event_to_synchronize[base_event][0][1].OE.event_id, new_google_event_id)
if event_to_synchronize[base_event][0][1].OE.event_id:
parent_event['id'] = "%s-%s" % (event_to_synchronize[base_event][0][1].OE.event_id, new_google_event_id)
else:
main_ev = att_obj.search_read(cr, uid, [('google_internal_event_id', '=', event.GG.event['id'].rsplit('_', 1)[0])], fields=['event_id'], context=context)
parent_event['id'] = "%s-%s" % (main_ev[0].get('event_id')[0], new_google_event_id)
res = self.update_from_google(cr, uid, parent_event, event.GG.event, "copy", context)
else:
if event_to_synchronize[base_event][0][1].OE.event_id: