summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2017-09-22 14:52:31 +0200
committerAdrian Torres <adt@odoo.com>2017-09-26 09:30:17 +0200
commit83024ca3d64b1a61c4807f184c93d9ca51f396b2 (patch)
tree5329c2a38d696470193ce3600bd126a96ef4776e
parent28755e1f41b2618d8fff04cde9916b52a6a986f6 (diff)
[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
-rw-r--r--addons/calendar/models/calendar.py22
1 files 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):