[FIX] google_calendar: sync when chenging the recurrency only

When changing anything regarding the recurrence,
e.g. the number of repetitions, the weekdays, ...
the event require an update by Google side

As the `rrule` is a computed field, we need to mark
the event as needing an update by Google side as soon
as one of the fields on which depend the `rrule` field
is updated.

opw-659963
This commit is contained in:
Denis Ledoux 2016-01-08 18:08:35 +01:00
parent 7041b2589a
commit 11c312182f
2 changed files with 11 additions and 7 deletions

View File

@ -825,6 +825,11 @@ class calendar_event(osv.Model):
meeting_data[field] = meeting.stop_date if meeting.allday else meeting.stop_datetime
return res
def _get_recurrent_fields(self, cr, uid, context=None):
return ['byday', 'recurrency', 'final_date', 'rrule_type', 'month_by',
'interval', 'count', 'end_type', 'mo', 'tu', 'we', 'th', 'fr', 'sa',
'su', 'day', 'week_list']
def _get_rulestring(self, cr, uid, ids, name, arg, context=None):
"""
Gets Recurrence rule string according to value type RECUR of iCalendar from the values given.
@ -835,10 +840,8 @@ class calendar_event(osv.Model):
ids = [ids]
#read these fields as SUPERUSER because if the record is private a normal search could raise an error
events = self.read(cr, SUPERUSER_ID, ids,
['id', 'byday', 'recurrency', 'final_date', 'rrule_type', 'month_by',
'interval', 'count', 'end_type', 'mo', 'tu', 'we', 'th', 'fr', 'sa',
'su', 'day', 'week_list'], context=context)
recurrent_fields = self._get_recurrent_fields(cr, uid, context=context)
events = self.read(cr, SUPERUSER_ID, ids, recurrent_fields, context=context)
for event in events:
if event['recurrency']:
result[event['id']] = self.compute_rule_string(event)

View File

@ -989,9 +989,10 @@ class calendar_event(osv.Model):
_inherit = "calendar.event"
def get_fields_need_update_google(self, cr, uid, context=None):
return ['name', 'description', 'allday', 'start', 'date_end', 'stop',
'attendee_ids', 'alarm_ids', 'location', 'class', 'active',
'start_date', 'start_datetime', 'stop_date', 'stop_datetime']
recurrent_fields = self._get_recurrent_fields(cr, uid, context=context)
return recurrent_fields + ['name', 'description', 'allday', 'start', 'date_end', 'stop',
'attendee_ids', 'alarm_ids', 'location', 'class', 'active',
'start_date', 'start_datetime', 'stop_date', 'stop_datetime']
def write(self, cr, uid, ids, vals, context=None):
if context is None: