[MERGE] [FIX] base_calendar: correct the set method for rrule (opw 605088)
- create hook method to fix the invalid call while keeping the signature of the old methdo - remove undeclared variable - force the 'byday' field (type selection) to be a string value instead of an integer bzr revid: mat@openerp.com-20140313155131-e90stgoh8bz8tgvg
This commit is contained in:
commit
5fa7e40a9f
|
@ -1015,15 +1015,20 @@ 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):
|
||||
if not isinstance(ids, list):
|
||||
ids = [ids]
|
||||
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 +1056,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 +1380,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'
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue