From 5a97745d424ca22a540f0b015f1acc8949083fb5 Mon Sep 17 00:00:00 2001 From: Marc Durepos Date: Thu, 12 Dec 2024 08:45:11 -0500 Subject: [PATCH] [FIX] set timezone on context if empty in event and user Prior to this commit, synchronizing an event to the CalDAV server could break in the _add_event_dates method if both self.event_tz and self.env.user.tz were empty (False). This should be a rare occurrence, but adding a fallback of self._context.get('tz') should help. --- caldav_sync/__manifest__.py | 2 +- caldav_sync/models/calendar_event.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/caldav_sync/__manifest__.py b/caldav_sync/__manifest__.py index 1434baa..d03351c 100644 --- a/caldav_sync/__manifest__.py +++ b/caldav_sync/__manifest__.py @@ -8,7 +8,7 @@ { "name": "CalDAV Synchronization", - "version": "17.0.0.6.0", + "version": "17.0.0.6.1", "license": "LGPL-3", "category": "Productivity", "summary": "Synchronize Odoo Calendar Events with CalDAV Servers", diff --git a/caldav_sync/models/calendar_event.py b/caldav_sync/models/calendar_event.py index e13ead3..d00b2a8 100644 --- a/caldav_sync/models/calendar_event.py +++ b/caldav_sync/models/calendar_event.py @@ -453,7 +453,7 @@ class CalendarEvent(models.Model): def _add_event_dates(self, event_data: Dict) -> None: """Add pertinent dates to event data, based on self.""" - tz = self.event_tz or self.env.user.tz + tz = self.event_tz or self.env.user.tz or self._context.get('tz') event_tz = timezone(tz) event_data["last-modified"] = vDatetime( utc.localize(self.write_date).astimezone(event_tz)