from osv import fields, osv
from tools.translate import _
import tools
-import mx.DateTime
import re
@param uid: the current user’s ID for security checks,
@param fields: List of fields for default value
@param context: A standard dictionary for contextual values
-
"""
- crm_obj = self.pool.get('crm.meeting')
- for meeting in crm_obj.browse(cr, uid, context.get('active_ids', [])):
- if not meeting.rrule:
- raise osv.except_osv(_("Warning !"), _("Please Apply Recurrency after Apply Exception Rule"))
+ if context is None:
+ context = {}
+ event_obj = self.pool.get(context.get('active_model'))
+ for event in event_obj.browse(cr, uid, context.get('active_ids', []), context=context):
+ if not event.rrule:
+ raise osv.except_osv(_("Warning !"), _("Please Apply Recurrency before applying Exception Rule."))
return False
def compute_exrule_string(self, cr, uid, ids, context=None):
weekstring = ''
monthstring = ''
yearstring = ''
-
+ if context is None:
+ context = {}
+ ex_id = base_calendar.base_calendar_id2real_id(context.get('active_id', False))
+ model = context.get('model', False)
+ model_obj = self.pool.get(model)
for datas in self.read(cr, uid, ids, context=context):
freq = datas.get('freq')
if freq == 'None':
- return ''
+ model_obj.write(cr, uid, ex_id,{'exrule': ''})
+ return{}
interval_srting = datas.get('interval') and (';INTERVAL=' + str(datas.get('interval'))) or ''
exrule_string = 'FREQ=' + freq.upper() + weekstring + interval_srting \
+ enddate + monthstring + yearstring
- ex_id = base_calendar.base_calendar_id2real_id(context['active_id'])
- model = context.get('model', False)
- model_obj = self.pool.get(model)
- exrule_value = model_obj.write(cr, uid,ex_id,{
- 'exrule': exrule_string,
- })
- return {}
+
+ model_obj.write(cr, uid, ex_id,{'exrule': exrule_string})
+ return {'type': 'ir.actions.act_window_close'}
_defaults = {
'freq': lambda *x: 'None',