[FIX] calendar: do not create events past year 9999

datetime.date(year, month, day).weekday() is undefined for year > 9999.
When creating a google recurrent event that is set to never end,
Odoo tries to create 100 individual events.
If in Google calendar the user sets a recurring event to a custom interval,
of say a century, then the hundredth event is in 100x100 years, so in 12018.
Since 12018 > 9999, we get a traceback and synchronisation never happens.

opw 1845311
This commit is contained in:
len-odoo
2018-05-23 09:11:20 +02:00
committed by Nicolas Martinelli
parent 793438915a
commit 4e57f94ff9
+7 -1
View File
@@ -655,7 +655,13 @@ class Meeting(models.Model):
}[data['rrule_type']]
deadline = fields.Datetime.from_string(data['stop'])
return deadline + relativedelta(**{delay: count * mult})
computed_final_date = False
while not computed_final_date and count > 0:
try: # may crash if year > 9999 (in case of recurring events)
computed_final_date = deadline + relativedelta(**{delay: count * mult})
except ValueError:
count -= data['interval']
return computed_final_date or deadline
return final_date
@api.multi