[FIX] calendar: all day event

- Set the TZ as 'America/Martinique'
- In the calendar (month view), click on a date D.
- Fill in the topic, then click on "Edit"

The date is set to D-1.

Commit 09066fbbd5 makes the date consistent when the user sets an
event as an all day event by taking into account the appropriate
timezone.

However, in the case of an event created from the month view, this TZ
modification should not be applied.

opw-766638
This commit is contained in:
Nicolas Martinelli
2017-09-05 16:33:04 +02:00
parent e300a587b3
commit d522a796d3
+9 -2
View File
@@ -975,6 +975,7 @@ class calendar_event(osv.Model):
def onchange_allday(self, cr, uid, ids, start=False, end=False, starttime=False, endtime=False, startdatetime=False, enddatetime=False, checkallday=False, context=None):
value = {}
context = context or {}
if not ((starttime and endtime) or (start and end)): # At first intialize, we have not datetime
return value
@@ -983,12 +984,18 @@ class calendar_event(osv.Model):
startdatetime = startdatetime or start
if startdatetime:
start = datetime.strptime(startdatetime, DEFAULT_SERVER_DATETIME_FORMAT)
value['start_date'] = fields.date.context_today(self, cr, uid, context=context, timestamp=start)
if context.get('default_allday'):
value['start_date'] = datetime.strftime(start, DEFAULT_SERVER_DATE_FORMAT)
else:
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'] = fields.date.context_today(self, cr, uid, context=context, timestamp=end)
if context.get('default_allday'):
value['stop_date'] = datetime.strftime(end, DEFAULT_SERVER_DATE_FORMAT)
else:
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