if default is None:
default = {}
- default.update({
- 'message_ids': [],
- })
+ default.update({ 'message_ids': [], })
if hasattr(self, '_columns'):
if self._columns.get('date_closed'):
- default.update({
- 'date_closed': False,
- })
+ default.update({ 'date_closed': False, })
if self._columns.get('date_open'):
- default.update({
- 'date_open': False
- })
+ default.update({ 'date_open': False })
- return super(osv.osv, self).copy(cr, uid, id, default, context=context)
+ return super(crm_case, self).copy(cr, uid, id, default, context=context)
-
-
-
-
- def _find_next_stage(self, cr, uid, stage_list, index, current_seq, stage_pool, context=None):
- if index + 1 == len(stage_list):
- return False
- next_stage_id = stage_list[index + 1]
- next_stage = stage_pool.browse(cr, uid, next_stage_id, context=context)
- if not next_stage:
- return False
- next_seq = next_stage.sequence
- if not current_seq :
- current_seq = 0
-
- if (abs(next_seq - current_seq)) >= 1:
- return next_stage
- else :
- return self._find_next_stage(cr, uid, stage_list, index + 1, current_seq, stage_pool)
-
- def stage_change(self, cr, uid, ids, context=None, order='sequence'):
- if context is None:
- context = {}
-
- stage_pool = self.pool.get('crm.case.stage')
- stage_type = context and context.get('stage_type','')
- current_seq = False
- next_stage_id = False
-
- for case in self.browse(cr, uid, ids, context=context):
-
- next_stage = False
- value = {}
- if case.section_id.id :
- domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)]
- else :
- domain = [('type', '=', stage_type)]
-
-
- stages = stage_pool.search(cr, uid, domain, order=order)
- current_seq = case.stage_id.sequence
- index = -1
- if case.stage_id and case.stage_id.id in stages:
- index = stages.index(case.stage_id.id)
-
- next_stage = self._find_next_stage(cr, uid, stages, index, current_seq, stage_pool, context=context)
-
- if next_stage:
- next_stage_id = next_stage.id
- value.update({'stage_id': next_stage.id})
- if next_stage.on_change:
- value.update({'probability': next_stage.probability})
- self.write(cr, uid, [case.id], value, context=context)
-
-
- return next_stage_id #FIXME should return a list of all id
-
-
- def stage_next(self, cr, uid, ids, context=None):
- """This function computes next stage for case from its current stage
- using available stage for that case type
- @param self: The object pointer
- @param cr: the current row, from the database cursor,
- @param uid: the current user’s ID for security checks,
- @param ids: List of case IDs
- @param context: A standard dictionary for contextual values"""
-
- return self.stage_change(cr, uid, ids, context=context, order='sequence')
-
- def stage_previous(self, cr, uid, ids, context=None):
- """This function computes previous stage for case from its current stage
- using available stage for that case type
- @param self: The object pointer
- @param cr: the current row, from the database cursor,
- @param uid: the current user’s ID for security checks,
- @param ids: List of case IDs
- @param context: A standard dictionary for contextual values"""
- return self.stage_change(cr, uid, ids, context=context, order='sequence desc')
-
-
-
-
-
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=[], context=None):
mailgate_pool = self.pool.get('mailgate.thread')
return mailgate_pool.history(cr, uid, cases, keyword, history=history,\