From d382d411c30ed96ac84d6fe0549bebdcc1d9ed85 Mon Sep 17 00:00:00 2001 From: Arnaud Joset Date: Mon, 23 Nov 2020 13:42:01 +0000 Subject: [PATCH] [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) --- addons/google_calendar/models/google_sync.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/google_calendar/models/google_sync.py b/addons/google_calendar/models/google_sync.py index bb34d9c7376..a16cce527f4 100644 --- a/addons/google_calendar/models/google_sync.py +++ b/addons/google_calendar/models/google_sync.py @@ -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