From 11c312182fc876a1def12ccf729f009db2c6b96a Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 8 Jan 2016 18:08:35 +0100 Subject: [PATCH] [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 --- addons/calendar/calendar.py | 11 +++++++---- addons/google_calendar/google_calendar.py | 7 ++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py index cead6d230a9..00c82af60db 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -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) diff --git a/addons/google_calendar/google_calendar.py b/addons/google_calendar/google_calendar.py index e9debc8f1bb..8f990ea075e 100644 --- a/addons/google_calendar/google_calendar.py +++ b/addons/google_calendar/google_calendar.py @@ -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: