From 83024ca3d64b1a61c4807f184c93d9ca51f396b2 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Fri, 22 Sep 2017 14:52:31 +0200 Subject: [PATCH] [FIX] calendar: Fix unicode reminders Before this commit, if a reminder was created and the dates being formatted contained unicode characters the whole thing would break because python + unicode is hard. Example: Japanese with Asia/Tokyo timezone and creating reminders of 1 day, see support ticket 771674 --- addons/calendar/models/calendar.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index fa22382b328..71125e76253 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -645,16 +645,30 @@ class Meeting(models.Model): date_deadline = fields.Datetime.context_timestamp(self.with_context(tz=timezone), fields.Datetime.from_string(stop)) # convert into string the date and time, using user formats - date_str = date.strftime(format_date) - time_str = date.strftime(format_time) + date_str = date.strftime(format_date).decode('utf-8') + time_str = date.strftime(format_time).decode('utf-8') if zallday: display_time = _("AllDay , %s") % (date_str) elif zduration < 24: duration = date + timedelta(hours=zduration) - display_time = _("%s at (%s To %s) (%s)") % (date_str, time_str, duration.strftime(format_time), timezone) + duration_time = duration.strftime(format_time).decode('utf-8') + display_time = _(u"%s at (%s To %s) (%s)") % ( + date_str, + time_str, + duration_time, + timezone, + ) else: - display_time = _("%s at %s To\n %s at %s (%s)") % (date_str, time_str, date_deadline.strftime(format_date), date_deadline.strftime(format_time), timezone) + dd_date = date_deadline.strftime(format_date).decode('utf-8') + dd_time = date_deadline.strftime(format_time).decode('utf-8') + display_time = _(u"%s at %s To\n %s at %s (%s)") % ( + date_str, + time_str, + dd_date, + dd_time, + timezone, + ) return display_time def _get_duration(self, start, stop):