[IMP] hr_recruitment :- improvement, add next and previous stage button, scheduled meeting button not work and other small changes.

bzr revid: ysa@tinyerp.co.in-20100407144028-vaya1ffdlqaqcdfj
This commit is contained in:
Ysa (Open ERP) 2010-04-07 20:10:28 +05:30
parent 6fce971a50
commit aa9afc1147
4 changed files with 97 additions and 70 deletions

View File

@ -20,6 +20,7 @@
##############################################################################
from osv import fields,osv,orm
from tools.translate import _
AVAILABLE_STATES = [
('draft','New'),
@ -54,14 +55,101 @@ class hr_applicant(osv.osv):
'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 users 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 users 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 users 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).

View File

@ -43,8 +43,8 @@
<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"/>
@ -71,8 +71,9 @@
<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"/>
@ -84,7 +85,8 @@
<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="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>

View File

@ -9,14 +9,6 @@
multi="True"
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"

View File

@ -132,61 +132,6 @@ class job2phonecall(wizard.interface):
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"?>