self.write(cr, uid, ids, { 'state' : 'cancel'}, context=context)
return True
+ 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 = {}
+ record = self.browse(cr, uid, ids, context)
+ record = record and record[0]
+ datas = {}
+ page_setting = {'orientation': 'vertical', 'without_pagebreak': 0, 'paper_size': 'letter', 'page_number': 1, 'survey_title': 1}
+ report = {}
+ if record:
+ datas['ids'] = [record.survey_id.id]
+ response_id = record.response.id
+ 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
+
+
hr_evaluation_interview()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:1
<group colspan="1">
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" states="waiting_answer,done,cancel"
icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': [response], 'response_no':0, 'active' : response,'request' : True, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
- <button name="%(survey.survey_browse_response)d" string="Print Interview" type="action" states="done"
- icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : [response], 'response_no':0,}" attrs="{'readonly':[('response','=',False)]}" />
+ <button name="action_print_survey" string="Print Interview" type="object" states="waiting_answer,done,cancel"
+ icon="gtk-print" attrs="{'readonly':[('survey_id','=',False)]}" />
</group>
</group>
<group col="4" colspan="4">
<field name="response" readonly="1" invisible="True"/>
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" states="waiting_answer,done,cancel"
icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': [response], 'response_no':0, 'active' : response, 'request' : True, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
- <button name="%(survey.survey_browse_response)d" string="Print Interview" type="action" states="done"
- icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : [response], 'response_no':0}" attrs="{'readonly':[('response','=',False)]}" />
+ <button name="action_print_survey" string="Print Interview" type="object" states="waiting_answer,done,cancel"
+ icon="gtk-print" attrs="{'readonly':[('survey_id','=',False)]}"/>
<field name="state"/>
</tree>
</field>
##############################################################################
from osv import fields,osv,orm
+from tools.translate import _
AVAILABLE_STATES = [
('draft','New'),
'partner_name': fields.char("Applicant's Name", size=64),
'partner_phone': fields.char('Phone', size=32),
'partner_mobile': fields.char('Mobile', size=32),
- 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'hr.applicant')]"),
- 'type_id': fields.many2one('crm.case.resource.type', 'Degree', domain="[('section_id','=',section_id),('object_id.model', '=', 'hr.applicant')]"),
+ 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('object_id.model', '=', 'hr.applicant')]"),
+ 'type_id': fields.many2one('crm.case.resource.type', 'Degree', domain="[('object_id.model', '=', 'hr.applicant')]"),
'department_id':fields.many2one('hr.department','Department'),
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
'survey' : fields.related('job_id', 'survey_id', type='many2one', relation='survey', string='Survey'),
'response' : fields.integer("Response"),
}
+
+ 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
+
hr_applicant()
class hr_job(osv.osv):
<field name="partner_phone"/>
<field name="job_id"/>
<field name="stage_id"/>
- <button name="stage_previous" string="Previous" states="open,pending" type="object" icon="gtk-go-back"/>
- <button name="stage_next" string="Next" states="open,pending" type="object" icon="gtk-go-forward"/>
+ <button name="stage_previous" string="Previous" states="draft,open,cancel,done,pending" type="object" icon="gtk-go-back"/>
+ <button name="stage_next" string="Next" states="draft,open,cancel,done,pending" type="object" icon="gtk-go-forward"/>
<field name="survey" invisible="1"/>
<field name="response" invisible="1"/>
<field name="priority"/>
<group colspan="4" col="8">
<field name="name" string="Subject"/>
<label string="Stage: " align="1.0"/>
- <group colspan="1" col="2">
+ <group colspan="1" col="3">
<field name="stage_id" nolabel="1"/>
+ <button name="stage_previous" string="" type="object" icon="gtk-go-back"/>
<button icon="gtk-go-forward" string="" name="stage_next" type="object"/>
</group>
<field name="user_id"/>
<field name="partner_name"/>
<field name="job_id"/>
<field name="department_id" widget="selection"/>
- <button name="%(wizard_hr_job_meeting_set)d" string="Schedule Meeting" icon="terp-hr" type="action"/>
- <button name="%(survey.survey_browse_response)d" string="Print Interview" type="action"
- icon="gtk-print" context="{'survey_id': survey, 'response_id' : [response], 'response_no':0,}" attrs="{'readonly':[('response','=',False)]}" />
- </group>
+ <button name="action_makeMeeting" type="object"
+ string="Schedule Meeting" icon="terp-hr" />
+ <button name="action_print_survey" string="Print Interview" type="object"
+ icon="gtk-print" attrs="{'readonly':[('survey','=',False)]}"/>
+ </group>
<notebook colspan="4">
<page string="Job Info">
<group col="2" colspan="2">
string="Schedule Phone Call" />
<wizard
- id="wizard_hr_job_meeting_set"
- keyword="client_action_multi"
- model="hr.applicant"
- name="hr.applicant.meeting_set"
- multi="True"
- string="Schedule Meeting"/>
-
- <wizard
id="wizard_hr_job_partner_create"
keyword="client_action_multi"
model="hr.applicant"
job2phonecall('hr.applicant.reschedule_phone_call')
-class job2meeting(wizard.interface):
-
- def _makeMeeting(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- job_case_obj = pool.get('hr.applicant')
- meeting_case_obj = pool.get('hr.meeting')
- for job in job_case_obj.browse(cr, uid, data['ids']):
- new_meeting_id = meeting_case_obj.create(cr, uid, {
- 'name': job.name,
- 'date': job.date,
- 'duration': job.duration,
- })
- new_meeting = meeting_case_obj.browse(cr, uid, new_meeting_id)
- vals = {}
- job_case_obj.write(cr, uid, [job.id], vals)
- job_case_obj.case_cancel(cr, uid, [job.id])
- meeting_case_obj.case_open(cr, uid, [new_meeting_id])
-
- data_obj = pool.get('ir.model.data')
- result = data_obj._get_id(cr, uid, 'hr', 'view_hr_case_meetings_filter')
- id = data_obj.read(cr, uid, result, ['res_id'])
- id1 = data_obj._get_id(cr, uid, 'hr', 'hr_case_calendar_view_meet')
- id2 = data_obj._get_id(cr, uid, 'hr', 'hr_case_form_view_meet')
- id3 = data_obj._get_id(cr, uid, 'hr', 'hr_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
- return {
- 'name': _('Meetings'),
- 'view_type': 'form',
- 'view_mode': 'calendar,form,tree',
- 'res_model': 'hr.meeting',
- 'view_id': False,
- 'views': [(id1,'calendar'),(id2,'form'),(id3,'tree'),(False,'graph')],
- 'type': 'ir.actions.act_window',
- 'search_view_id': id['res_id']
- }
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _makeMeeting, 'state': 'order'}
- },
- 'order': {
- 'actions': [],
- 'result': {'type': 'state', 'state': 'end'}
- }
- }
-
-job2meeting('hr.applicant.meeting_set')
-
-
class partner_create(wizard.interface):
case_form = """<?xml version="1.0"?>
def copy(self, cr, uid, id, default=None,context={}):
raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!'))
+ 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 = {}
+ response_id = self.pool.get('survey.response').search(cr, uid, [('survey_id','=', ids)], context=context)
+ page_setting = {'orientation': 'vertical', 'without_pagebreak': 0, 'paper_size': 'letter', 'page_number': 1, 'survey_title': 1}
+ report = {}
+ datas['ids'] = ids
+ if response_id:
+ context.update({'survey_id': datas['ids']})
+ 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
+
survey()
class survey_history(osv.osv):
string="Answer Survey" type="action" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}"/>
<button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel"
string="Edit Survey" type="action" icon="gtk-edit" context="{'active':True,'edit' : True,'survey_id': active_id}"/>
- <button name="%(survey_browse_response)d" states="open,draft,close,cancel"
- string="Print Answer" type="action" icon="gtk-print"/>
+ <button name="action_print_survey" states="open,draft,close,cancel"
+ string="Print Answer" type="object" icon="gtk-print"/>
</tree>
</field>
</record>