From 8b63f15e277d9a014f1a4c0a569e442a95fcdeb5 Mon Sep 17 00:00:00 2001 From: "jerome hanke (jhk)" Date: Tue, 18 Feb 2020 14:18:41 +0000 Subject: [PATCH] [FIX] calendar: recurring events can have 0 repetitions Steps to reproduce: - install calendar - create a recurring event with 0 repetitions - save Previous behavior: raises an UserError, this would interrupt the sync with google calendar Google calendar sometimes sets recurring events to 0 repetitions once they are done recurring Current behavior: the event is handled like a punctual event but remains recurrent initial commit: https://github.com/odoo/odoo/commit/ba727e15d2dc9a1325cd20527e2ccfe6f8bc63f0 opw-2185699 closes odoo/odoo#45947 X-original-commit: 5b63ddb4e03f34f015e7668c69108fb4a2badd08 Signed-off-by: mightyjol --- 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 586f0c630ef..59a8a11bcda 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -1235,7 +1235,7 @@ class Meeting(models.Model): """ if self.interval <= 0: raise UserError(_('The interval cannot be negative.')) - if self.end_type == 'count' and self.count <= 0: + if self.end_type == 'count' and self.count < 0: raise UserError(_('The number of repetitions cannot be negative.')) def get_week_string(freq): @@ -1260,7 +1260,7 @@ class Meeting(models.Model): def get_end_date(): final_date = fields.Date.to_string(self.final_date) end_date_new = ''.join((re.compile('\d')).findall(final_date)) + 'T235959Z' if final_date else False - return (self.end_type == 'count' and (';COUNT=' + str(self.count)) or '') +\ + return (self.end_type == 'count' and (';COUNT=' + str(max(1, self.count))) or '') +\ ((end_date_new and self.end_type == 'end_date' and (';UNTIL=' + end_date_new)) or '') freq = self.rrule_type # day/week/month/year