[FIX] base_calendar: correct the invert call to the function field rrule.
authorMartin Trigaux <mat@openerp.com>
Thu, 13 Mar 2014 15:08:23 +0000 (16:08 +0100)
committerMartin Trigaux <mat@openerp.com>
Thu, 13 Mar 2014 15:08:23 +0000 (16:08 +0100)
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

index 44c598f..fd45cab 100644 (file)
@@ -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'