+
+ 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"""
+ if not context:
+ context = {}
+ for case in self.browse(cr, uid, ids, context):
+ section = (case.section_id.id or False)
+ st = case.stage_id.id or False
+ stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [])
+ if st and stage_ids.index(st):
+ self.write(cr, uid, [case.id], {'stage_id': stage_ids[stage_ids.index(st)-1]})
+ return True
+
+ 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"""
+ if not context:
+ context = {}
+ for case in self.browse(cr, uid, ids, context):
+ section = (case.section_id.id or False)
+ st = case.stage_id.id or False
+ stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [])
+ if st and len(stage_ids) != stage_ids.index(st)+1:
+ self.write(cr, uid, [case.id], {'stage_id': stage_ids[stage_ids.index(st)+1]})
+ return True
+
+ def action_makeMeeting(self, cr, uid, ids, context=None):
+ """
+ This opens Meeting's calendar view to schedule meeting on current Opportunity
+ @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 Opportunity to Meeting IDs
+ @param context: A standard dictionary for contextual values
+
+ @return : Dictionary value for created Meeting view
+ """
+ value = {}
+ for opp in self.browse(cr, uid, ids):
+ data_obj = self.pool.get('ir.model.data')
+
+ # Get meeting views
+ result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter')
+ res = data_obj.read(cr, uid, result, ['res_id'])
+ id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet')
+ id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet')
+ id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet')
+ if id1:
+ id1 = data_obj.browse(cr, uid, id1, context=context).res_id
+ if id2:
+ id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+ if id3:
+ id3 = data_obj.browse(cr, uid, id3, context=context).res_id
+
+ context = {
+ 'default_opportunity_id': opp.id,
+ 'default_partner_id': opp.partner_id and opp.partner_id.id or False,
+ 'default_section_id': opp.section_id and opp.section_id.id or False,
+ 'default_email_from': opp.email_from,
+ 'default_state': 'open',
+ 'default_name': opp.name
+ }
+ value = {
+ 'name': _('Meetings'),
+ 'domain': "[('user_id','=',%s)]" % (uid),
+ 'context': context,
+ 'view_type': 'form',
+ 'view_mode': 'calendar,form,tree',
+ 'res_model': 'crm.meeting',
+ 'view_id': False,
+ 'views': [(id1, 'calendar'), (id2, 'form'), (id3, 'tree')],
+ 'type': 'ir.actions.act_window',
+ 'search_view_id': res['res_id'],
+ 'nodestroy': True
+ }
+ return value
+
+ def action_print_survey(self, cr, uid, ids, context=None):
+ """
+ If response is available then print this response otherwise print survey form(print template of the survey).
+
+ @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 Survey IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for print survey form.
+ """
+ if not context:
+ context = {}
+ datas = {}
+ record = self.browse(cr, uid, ids, context)
+ record = record and record[0]
+ page_setting = {'orientation': 'vertical', 'without_pagebreak': 0, 'paper_size': 'letter', 'page_number': 1, 'survey_title': 1}
+ report = {}
+ if record:
+ datas['ids'] = [record.survey.id]
+ response_id = record.response
+ if response_id:
+ context.update({'survey_id': datas['ids'], 'response_id' : [response_id], 'response_no':0,})
+ datas['form'] = page_setting
+ datas['model'] = 'survey.print.answer'
+ report = {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'survey.browse.response',
+ 'datas': datas,
+ 'nodestroy': True,
+ 'context' : context
+ }
+ else:
+ datas['form'] = page_setting
+ datas['model'] = 'survey.print'
+ report = {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'survey.form',
+ 'datas': datas,
+ 'nodestroy':True,
+ 'context' : context
+ }
+ return report
+