[FIX]: google_calendar: check write_date when syncing with google

When the database is migrated from 13.3 to 14.0, the write_date is not set on the 'calendar.event' records.
During the syncing with google api, the write-date is compared to take the more recent values, leading to an inevitable crash for recently migrated databases.

closes odoo/odoo#63007

Taskid: 2389374
X-original-commit: e1493af550bd425ca682e4db707e5a490d3d4af8
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Arnaud Joset
2020-12-08 11:31:50 +00:00
parent 923b38ba39
commit d382d411c3
+2 -1
View File
@@ -168,7 +168,8 @@ class GoogleSync(models.AbstractModel):
# This could be dangerous if google server time and odoo server time are different
updated = parse(gevent.updated)
odoo_record = self.browse(gevent.odoo_id(self.env))
if updated >= pytz.utc.localize(odoo_record.write_date):
# 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)
synced_records |= odoo_record