[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 <jhk-odoo@users.noreply.github.com>
This commit is contained in:
jerome hanke (jhk)
2020-02-21 13:49:06 +00:00
parent 952c668b82
commit 8b63f15e27
+2 -2
View File
@@ -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