From 3e7b87398757b20ab489c8f7ddf9914e43df237d Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 13 Mar 2014 16:08:23 +0100 Subject: [PATCH 1/3] [FIX] base_calendar: correct the invert call to the function field rrule. Create new hook method with valid signature. Keep the old one for compatibility reasons. Force the value of 'byday' (type selection) to be a string instead of integer. bzr revid: mat@openerp.com-20140313150823-vba9qulj549v37t9 --- addons/base_calendar/base_calendar.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 44c598f5ef6..fd45cab01c0 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1015,15 +1015,18 @@ class calendar_event(osv.osv): result[event] = "" return result + # hook method to fix the wrong signature + def _set_rulestring(self, cr, uid, ids, field_name, field_value, args, context=None): + return self._rrule_write(self, cr, uid, ids, field_name, field_value, args, context=context) + def _rrule_write(self, obj, cr, uid, ids, field_name, field_value, args, context=None): data = self._get_empty_rrule_data() if field_value: data['recurrency'] = True for event in self.browse(cr, uid, ids, context=context): - rdate = rule_date or event.date - update_data = self._parse_rrule(field_value, dict(data), rdate) + update_data = self._parse_rrule(field_value, dict(data), event.date) data.update(update_data) - super(calendar_event, obj).write(cr, uid, ids, data, context=context) + super(calendar_event, self).write(cr, uid, ids, data, context=context) return True _columns = { @@ -1051,7 +1054,7 @@ defines the list of date/time exceptions for a recurring calendar component."), 'exrule': fields.char('Exception Rule', size=352, help="Defines a \ rule or repeating pattern of time to exclude from the recurring rule."), 'rrule': fields.function(_get_rulestring, type='char', size=124, \ - fnct_inv=_rrule_write, store=True, string='Recurrent Rule'), + fnct_inv=_set_rulestring, store=True, string='Recurrent Rule'), 'rrule_type': fields.selection([ ('daily', 'Day(s)'), ('weekly', 'Week(s)'), @@ -1375,7 +1378,7 @@ rule or repeating pattern of time to exclude from the recurring rule."), #repeat monthly by nweekday ((weekday, weeknumber), ) if r._bynweekday: data['week_list'] = day_list[r._bynweekday[0][0]].upper() - data['byday'] = r._bynweekday[0][1] + data['byday'] = str(r._bynweekday[0][1]) data['select1'] = 'day' data['rrule_type'] = 'monthly' From 125261499ddd0ebfeb0f974262962366a8800525 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 13 Mar 2014 16:16:12 +0100 Subject: [PATCH 2/3] [FIX] if only one id, convert to list bzr revid: mat@openerp.com-20140313151612-saoc3a73x1cwvgbg --- addons/base_calendar/base_calendar.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index fd45cab01c0..fc4261afe82 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1020,6 +1020,8 @@ class calendar_event(osv.osv): return self._rrule_write(self, cr, uid, ids, field_name, field_value, args, context=context) def _rrule_write(self, obj, cr, uid, ids, field_name, field_value, args, context=None): + if not isinstance(ids, list): + ids = [ids] data = self._get_empty_rrule_data() if field_value: data['recurrency'] = True From 219e1a62182ed178389a0f60141f9bda7853423b Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 13 Mar 2014 16:37:57 +0100 Subject: [PATCH 3/3] [IMP] add test bzr revid: mat@openerp.com-20140313153757-nj9nn52u7kxpfg8i --- .../base_calendar/test/base_calendar_test.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/addons/base_calendar/test/base_calendar_test.yml b/addons/base_calendar/test/base_calendar_test.yml index 7afd2e49551..c280bfe298a 100644 --- a/addons/base_calendar/test/base_calendar_test.yml +++ b/addons/base_calendar/test/base_calendar_test.yml @@ -52,3 +52,20 @@ - !python {model: calendar.event}: | self.write(cr, uid, [ref("calendar_event_alldaytestevent0")], {'alarm_id': ref("res_alarm_daybeforeeventstarts0")}) +- + I create a recuring rule for my event +- + !record {model: crm.meeting, id: crm_meeting_sprintreview1}: + name: Begin of month meeting + date: !eval time.strftime('%Y-%m-%d 12:00:00') + recurrency: true + rrule: FREQ=MONTHLY;INTERVAL=1;COUNT=12;BYDAY=1MO +- + I check that the attributes are set correctly +- + !assert {model: crm.meeting, id: crm_meeting_sprintreview1}: + - rrule_type == 'monthly' + - count == 12 + - select1 == 'day' + - byday == '1' + - week_list == 'MO'