From e75c0bd2b97659efeb89825e1105cb4b961b89e3 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 20 Jun 2018 12:24:28 +0200 Subject: [PATCH] [FIX] calendar: ensure the recurring dates is inside the limit defined by datetime The library `datetime` defines a MINYEAR and MAXYEAR limit. If you try to play with dates outside of these years limits, it crashes. In the case of the opw, the date within its timezone was within the limit (year 9999), but in the UTC timezone it was no longer the case (year 10000). Actually the condition should use `<=` instead of strict `<`, and check the year *in utc* is not outside the limit, but as soon as you try to compute the date within UTC, datetime crashes :). However we can assume nobody will need a event in the year 9999 any time soon, or by that time if Odoo still exists, we should have refactored this module about 3333 times and somebody would probably have removed this limitation by oversight anyway. opw-1850024 --- addons/calendar/models/calendar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 757d425d39c..99abf2a786a 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -4,7 +4,7 @@ import base64 import babel.dates import collections -from datetime import datetime, timedelta +from datetime import datetime, timedelta, MAXYEAR from dateutil import parser from dateutil import rrule from dateutil.relativedelta import relativedelta @@ -632,7 +632,7 @@ class Meeting(models.Model): recurring_date = todate(meeting.recurrent_id_date) rset1.exdate(recurring_date) invalidate = True - return [d.astimezone(pytz.UTC) if d.tzinfo else d for d in rset1] + return [d.astimezone(pytz.UTC) if d.tzinfo else d for d in rset1 if d.year < MAXYEAR] @api.multi def _get_recurrency_end_date(self):