diff options
| author | Lucas Lefèvre <lul@odoo.com> | 2021-02-09 16:42:00 +0000 |
|---|---|---|
| committer | Arnaud Joset <arj@odoo.com> | 2021-03-22 11:00:32 +0000 |
| commit | 374d3c7f95fca9832afb0d34d710f28dbadcdfa6 (patch) | |
| tree | 5ea727d06eece30e4ac69a45e3f8b98c10c15e05 /addons/google_calendar/models/google_sync.py | |
| parent | e6675b075459c446a9115f9695824646c81dcc3f (diff) | |
[FIX] google_calendar: events sync issues
Before this commit:
The google synchronization dis not properly synced event in some conditions. Some use cases were not properly tested.
Recurrent events were regularly badly synchronized with Google.
Several issues occured:
- events not follow recurrence were duplicated on both Google or Odoo and sometimes deleted when the recurrence was reapplied.
- the base_event (first event of the recurrence) was duplicated
- miscalculation of the event google_id when they were part of a recurrence but did not followed the rrule.
- improper data handling from google. Odoo objets were created with incorrect values
- attendee state was not properly sync from Odoo to Google
- whole recurrence deletions from google were not properly sync in Odoo
- when time fields of a recurrence were modified on Google, modifications were ignored on Odoo
- Event timezone were not properly saved on the recurrency. (Odoo saves it on the recurrency and Google on the event)
- Odoo considered that all public events are writable bu Odoo users. That would trigger errors as Google implement an access right model on public events
- lack of tests
- a lot of weird behaviors resulting from these problems.
closes odoo/odoo#66080
Taskid: 2456498
Opw: 2299834
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Co-authored-by: Lucas Lefèvre <lul@odoo.com>
Co-authored-by: Arnaud Joset <arj@odoo.com>
Diffstat (limited to 'addons/google_calendar/models/google_sync.py')
| -rw-r--r-- | addons/google_calendar/models/google_sync.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/addons/google_calendar/models/google_sync.py b/addons/google_calendar/models/google_sync.py index c5c549b752f..e1486bac47e 100644 --- a/addons/google_calendar/models/google_sync.py +++ b/addons/google_calendar/models/google_sync.py @@ -155,8 +155,7 @@ class GoogleSync(models.AbstractModel): dict(self._odoo_values(e, default_reminders), need_sync=False) for e in new ] - new_odoo = self.create(odoo_values) - + new_odoo = self._create_from_google(new, odoo_values) cancelled = existing.cancelled() cancelled_odoo = self.browse(cancelled.odoo_ids(self.env)) cancelled_odoo._cancel() @@ -170,7 +169,7 @@ class GoogleSync(models.AbstractModel): # Migration from 13.4 does not fill write_date. Therefore, we force the update from Google. if not odoo_record.write_date or updated >= pytz.utc.localize(odoo_record.write_date): vals = dict(self._odoo_values(gevent, default_reminders), need_sync=False) - odoo_record.write(vals) + odoo_record._write_from_google(gevent, vals) synced_records |= odoo_record return synced_records @@ -180,7 +179,9 @@ class GoogleSync(models.AbstractModel): with google_calendar_token(self.env.user.sudo()) as token: if token: google_service.delete(google_id, token=token, timeout=timeout) - self.need_sync = False + # When the record has been deleted on our side, we need to delete it on google but we don't want + # to raise an error because the record don't exists anymore. + self.exists().need_sync = False @after_commit def _google_patch(self, google_service: GoogleCalendarService, google_id, values, timeout=TIMEOUT): @@ -217,6 +218,13 @@ class GoogleSync(models.AbstractModel): ]]) return self.with_context(active_test=False).search(domain) + def _write_from_google(self, gevent, vals): + self.write(vals) + + @api.model + def _create_from_google(self, gevents, vals_list): + return self.create(vals_list) + @api.model def _odoo_values(self, google_event: GoogleEvent, default_reminders=()): """Implements this method to return a dict of Odoo values corresponding |
