From 3418b9f8aa052ae0aabf940d6332cc0aa77d409d Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Mon, 25 Jul 2016 14:39:16 +0200 Subject: [PATCH] [FIX] calendar: avoid infinite recurrent event Old check was always ignored since 0 is False. This commit closes #12715 Other fix; when we detach an event, we reset the rrule_type to avoid to have a warning popup (about empty final_date) if the old one value was end_date. --- addons/calendar/calendar.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py index 5da9104b6a8..0c38539d677 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -1267,7 +1267,7 @@ class calendar_event(osv.Model): """ if data['interval'] and data['interval'] < 0: raise osv.except_osv(_('warning!'), _('interval cannot be negative.')) - if data['count'] and data['count'] <= 0: + if data['end_type'] == 'count' and int(data['count']) <= 0: raise osv.except_osv(_('warning!'), _('count cannot be negative or 0.')) def get_week_string(freq, data): @@ -1537,6 +1537,7 @@ class calendar_event(osv.Model): recurrent_id=real_event_id, recurrent_id_date=data.get('start'), rrule_type=False, + end_type=False, rrule='', recurrency=False, final_date=datetime.strptime(data.get('start'), DEFAULT_SERVER_DATETIME_FORMAT if data['allday'] else DEFAULT_SERVER_DATETIME_FORMAT) + timedelta(hours=values.get('duration', False) or data.get('duration'))