From 09066fbbd5dba833dfcc2e50e406a14eacc8c10b Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 22 Dec 2016 21:12:39 -0500 Subject: [PATCH] [FIX] calendar: fix allday onchange user tz While choosing a start/stop datetime in a timezone hour were the UTC value is within the next day, e.g. Start time Dec 22 20:00 in US/Eastner (UTC -5:00) Therefore, start time Dec 23 01:00 in UTC Checking the "all day" box made the start time set to Dec 23 instead of what the user expected, Dec 22. This is because the onchange simply took the UTC datetime (Dec 23 01:00) from which it removed the time (Dec 23). This revision make sure to remove the time from the user timezoned datetime instead, so the day set remain the same day than what was set in the datetime. opw-702065 --- addons/calendar/calendar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py index b5b0e073d16..14742cb1c3e 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -1016,12 +1016,12 @@ class calendar_event(osv.Model): startdatetime = startdatetime or start if startdatetime: start = datetime.strptime(startdatetime, DEFAULT_SERVER_DATETIME_FORMAT) - value['start_date'] = datetime.strftime(start, DEFAULT_SERVER_DATE_FORMAT) + value['start_date'] = fields.date.context_today(self, cr, uid, context=context, timestamp=start) enddatetime = enddatetime or end if enddatetime: end = datetime.strptime(enddatetime, DEFAULT_SERVER_DATETIME_FORMAT) - value['stop_date'] = datetime.strftime(end, DEFAULT_SERVER_DATE_FORMAT) + value['stop_date'] = fields.date.context_today(self, cr, uid, context=context, timestamp=end) else: # from date to datetime user = self.pool['res.users'].browse(cr, uid, uid, context) tz = pytz.timezone(user.tz) if user.tz else pytz.utc