Commit Graph
5 Commits
Author SHA1 Message Date
Lucas Lefèvre ae3d37c201 [REF] google_calendar: Refactor synchronisation
This commit refactors calendar synchronization between Odoo and Google after the
main calendar application refactoring.

This refactoring takes advantage of two new features from the Google API:

- New way of synchronizing resources efficiently[1]
Incremental sync is performed repeatedly and updates Odoo with all the changes that
happened ever since the previous sync. Each time, Odoo provides the previous sync
token it obtained from Google and stores the new sync token from the response.

- Event metadata[2]
Ability to set hidden key-value pairs with an event, called extended properties.
These extended properties are used to store the related odoo event id and the Odoo
owner id (see known limitations)

Known limitations
=================
- Let A and B be two new users (no tokens available). A creates an event in Odoo and
invites B. A is the owner of the event (user_id). Now B authenticates to his Google Calendar
account and synchronizes his calendar. We cannot send the event to A's calendar since we
don't have any access to his Google Calendar. Hence the event his sent to B's calendar.
This leads to data de-synchronisation: The owner is A in Odoo but B in Google.
The "real" owner (user A) is stored in the Google event's metadata to be able to
reconcile the owner for following synchronizations.

- Let A and B be two users of Odoo and Google Calendar. And let the Google Calendar of B
be private (e.g. if A creates an event in Google Calendar and invites B, B won't see the
event in his calendar). If A creates an event in Odoo and invites B. The event is synced
to Google Calendar of A. Now B can see the event in Odoo but he can't see it in his
Google Calendar.

Task 2126717
PR #42031
PR Enterprise odoo/enterprise#8006

[1] https://developers.google.com/calendar/v3/sync
[2] https://developers.google.com/calendar/extended-properties
2020-04-09 10:59:33 +02:00
sndandNicolas Martinelli f7eb653e7a [FIX] google_calendar: synchronization cron timeout
In a database with many users / events to synchronize, the cron
`ir_cron_sync_all_cals` may time out. Consequently, even if a `commit`
is performed for each user, some users are never synchronized.

In this commit, we first sort the users by last synchronization date,
meaning that all users will ultimately be synchronized, even if the cron
times out. On top of that, we introduce the context key
`last_sync_hours` to prevent the synchronization in case the cron is
restarted after timeout.

opw-2158372

closes odoo/odoo#45032

X-original-commit: 2f21def63c61324e2286dbee6abead091171a041
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Co-authored-by: Nicolas Martinelli <nim@odoo.com>
2020-02-10 17:38:28 +00:00
Thibault Delavallée 1c79c5ee30 [REF] ir_cron: make scheduled actions inherits from server actions
The purpose of this commit is to handle code execution only in server
action and delegate schedule management to ir_cron model.

ir.cron model now inherits from ir.actions.server. Fields model, function
and args are removed as well as the logic to handle them. There is no
more code manipulation and evaluation in ir_cron, only a call to the run
method of ir.actions.server.

Cron form view use server action form view as primary view. This way
automated actions use the same base form as server actions with
cron details added.

Thanks to @fpodoo for the original idea and preliminary work. Thanks to
@jpr-odoo for first developments. Thanks to @jem-odoo for reviewing.
2017-01-03 19:11:07 +01:00
Mohammed Shekha 9b39275d85 [MIG] google_calendar: migrate to new api
No behaviour changes, only migrate code and add
some docstring.
2016-08-08 16:27:06 +02:00
Mohammed Shekha d624fdd250 [MOV] google_calendar: moved models and data file in to models and data directory 2016-08-08 16:07:07 +02:00