Skip to content
Snippets Groups Projects
Commit b33b1bb3 authored by Mustufa Rangwala's avatar Mustufa Rangwala
Browse files

[ADD] hr_recruitement: Schedule phone call => osv memory

bzr revid: mra@tinyerp.com-20100423072909-rc83z1y710a9nhg4
parent 195a5197
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ system to store and search in your CV base.
'hr_recruitment_data.xml'
],
'update_xml': [
'wizard/hr_recruitment_phonecall_view.xml',
'hr_recruitment_wizard.xml',
'hr_recruitment_view.xml',
'hr_recruitment_menu.xml',
......@@ -46,7 +47,7 @@ system to store and search in your CV base.
'security/hr_recruitment_security.xml',
'security/ir.model.access.csv',
'board_hr_recruitment_statistical_view.xml',
'report/hr_recruitment_report_view.xml'
'report/hr_recruitment_report_view.xml',
],
'demo_xml': [
'hr_recruitment_demo.xml'
......
......@@ -78,7 +78,7 @@
</group>
<field name="user_id"/>
<button string="Schedule a Phone Call"
name="%(wizard_hr_job_reschedule_phone_call)d" icon="gtk-redo" type="action"/>
name="%(action_hr_recruitment_phonecall)d" icon="gtk-redo" type="action"/>
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action"
icon="gtk-execute" context="{'survey_id': survey, 'response_id': [response], 'response_no':0 ,'active' : response, 'object' : 'hr.applicant', 'cur_id' :active_id}" attrs="{'readonly':[('survey','=',False)]}"/>
<newline/>
......
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard
<!-- <wizard
id="wizard_hr_job_reschedule_phone_call"
keyword="client_action_multi"
model="hr.applicant"
name="hr.applicant.reschedule_phone_call"
multi="True"
string="Schedule Phone Call" />
-->
<wizard
id="wizard_hr_job_partner_create"
keyword="client_action_multi"
......
......@@ -20,7 +20,7 @@
##############################################################################
import hr_recruitment_wizard
import hr_recruitment_phonecall
......
......@@ -20,61 +20,53 @@
#
##############################################################################
from mx.DateTime import now
import wizard
import netsvc
import ir
import pooler
import time
from osv import osv, fields
from tools.translate import _
class job2phonecall(wizard.interface):
case_form = """<?xml version="1.0"?>
<form string="Schedule Phone Call">
<separator string="Phone Call Description" colspan="4" />
<newline />
<field name='user_id' />
<field name='deadline' />
<newline />
<field name='note' colspan="4"/>
<newline />
<field name='category_id'/>
</form>"""
#<field name='section_id' />
case_fields = {
'user_id' : {'string' : 'Assign To', 'type' : 'many2one', 'relation' : 'res.users'},
'deadline' : {'string' : 'Planned Date', 'type' : 'datetime'},
'note' : {'string' : 'Goals', 'type' : 'text'},
'category_id' : {'string' : 'Category', 'type' : 'many2one', 'relation' : 'crm.case.categ', 'required' : True},
#'section_id' : {'string' : 'Section', 'type' : 'many2one', 'relation' : 'hr.case.section'},
}
def _default_values(self, cr, uid, data, context):
case_obj = pooler.get_pool(cr.dbname).get('hr.applicant')
categ_id=pooler.get_pool(cr.dbname).get('crm.case.categ').search(cr, uid, [('name','=','Outbound')])
case = case_obj.browse(cr, uid, data['id'])
return {
'user_id' : case.user_id and case.user_id.id,
'category_id' : categ_id and categ_id[0] or case.categ_id and case.categ_id.id,
# 'section_id' : case.section_id and case.section_id.id or False,
'note' : case.description
}
def _doIt(self, cr, uid, data, context):
form = data['form']
pool = pooler.get_pool(cr.dbname)
mod_obj = pool.get('ir.model.data')
class job2phonecall(osv.osv_memory):
_name = 'hr.recruitment.job2phonecall'
_description = 'Schedule Phone Call'
_columns = {
'user_id': fields.many2one('res.users', 'Assign To'),
'deadline': fields.datetime('Planned Date'),
'note': fields.text('Goals'),
'category_id': fields.many2one('crm.case.categ', 'Category', required=True),
}
def _date_user(self, cr, uid, context=None):
case_obj = self.pool.get('hr.applicant')
case = case_obj.browse(cr, uid, context['active_id'])
return case.user_id and case.user_id.id or False
def _date_category(self, cr, uid, context=None):
categ_id = self.pool.get('crm.case.categ').search(cr, uid, [('name','=','Outbound')])
return categ_id and categ_id[0] or case.categ_id and case.categ_id.id or False
def _get_note(self, cr, uid, context=None):
case_obj = self.pool.get('hr.applicant')
case = case_obj.browse(cr, uid, context['active_id'])
return case.description or ''
_defaults = {
'user_id': _date_user,
'category_id': _date_category,
'note': _get_note
}
def make_phonecall(self, cr, uid, ids, context=None):
mod_obj = self.pool.get('ir.model.data')
job_case_obj = self.pool.get('hr.applicant')
data_obj = self.pool.get('ir.model.data')
phonecall_case_obj = self.pool.get('crm.phonecall')
form = self.read(cr, uid, ids, [], context=context)[0]
# form = data['form']
result = mod_obj._get_id(cr, uid, 'crm', 'view_crm_case_phonecalls_filter')
res = mod_obj.read(cr, uid, result, ['res_id'])
phonecall_case_obj = pool.get('crm.phonecall')
job_case_obj = pool.get('hr.applicant')
# Select the view
data_obj = pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_tree_view')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_form_view')
if id2:
......@@ -82,7 +74,7 @@ class job2phonecall(wizard.interface):
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
for job in job_case_obj.browse(cr, uid, data['ids']):
for job in job_case_obj.browse(cr, uid, context['active_ids']):
#TODO : Take other info from job
new_phonecall_id = phonecall_case_obj.create(cr, uid, {
'name' : job.name,
......@@ -106,6 +98,7 @@ class job2phonecall(wizard.interface):
job_case_obj.write(cr, uid, [job.id], vals)
job_case_obj.case_cancel(cr, uid, [job.id])
phonecall_case_obj.case_open(cr, uid, [new_phonecall_id])
value = {
'name': _('Phone Call'),
'view_type': 'form',
......@@ -118,101 +111,6 @@ class job2phonecall(wizard.interface):
}
return value
states = {
'init': {
'actions': [_default_values],
'result': {'type': 'form', 'arch': case_form, 'fields': case_fields,
'state' : [('end', 'Cancel','gtk-cancel'),('order', 'Schedule Phone Call','gtk-go-forward')]}
},
'order': {
'actions': [],
'result': {'type': 'action', 'action': _doIt, 'state': 'end'}
}
}
job2phonecall('hr.applicant.reschedule_phone_call')
class partner_create(wizard.interface):
case_form = """<?xml version="1.0"?>
<form string="Convert To Partner">
<label string="Are you sure you want to create a partner based on this job request ?" colspan="4"/>
<label string="You may have to verify that this partner does not exist already." colspan="4"/>
<!--field name="close"/-->
</form>"""
case_fields = {
'close': {'type':'boolean', 'string':'Close job request'}
}
def _selectPartner(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
case_obj = pool.get('hr.applicant')
for case in case_obj.browse(cr, uid, data['ids']):
if case.partner_id:
raise wizard.except_wizard(_('Warning !'),
_('A partner is already defined on this job request.'))
return {}
def _makeOrder(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
mod_obj = pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter')
res = mod_obj.read(cr, uid, result, ['res_id'])
case_obj = pool.get('hr.applicant')
partner_obj = pool.get('res.partner')
contact_obj = pool.get('res.partner.address')
for case in case_obj.browse(cr, uid, data['ids']):
partner_id = partner_obj.search(cr, uid, [('name', '=', case.partner_name or case.name)])
if partner_id:
raise wizard.except_wizard(_('Warning !'),_('A partner is already existing with the same name.'))
else:
partner_id = partner_obj.create(cr, uid, {
'name': case.partner_name or case.name,
'user_id': case.user_id.id,
'comment': case.description,
})
contact_id = contact_obj.create(cr, uid, {
'partner_id': partner_id,
'name': case.partner_name,
'phone': case.partner_phone,
'mobile': case.partner_mobile,
'email': case.email_from
})
case_obj.write(cr, uid, data['ids'], {
'partner_id': partner_id,
'partner_address_id': contact_id
})
if data['form']['close']:
case_obj.case_close(cr, uid, data['ids'])
value = {
'domain': "[]",
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'res.partner',
'res_id': int(partner_id),
'view_id': False,
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
states = {
'init': {
'actions': [_selectPartner],
'result': {'type': 'form', 'arch': case_form, 'fields': case_fields,
'state' : [('end', 'Cancel', 'gtk-cancel'),('confirm', 'Create Partner', 'gtk-go-forward')]}
},
'confirm': {
'actions': [],
'result': {'type': 'action', 'action': _makeOrder, 'state': 'end'}
}
}
partner_create('hr.applicant.partner_create')
job2phonecall()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_hr_recruitment_phonecall" model="ir.ui.view">
<field name="name">hr.recruitment.job2phonecall.form</field>
<field name="model">hr.recruitment.job2phonecall</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Schedule Phone Call">
<group col="4" colspan="6">
<separator string="Phone Call Description" colspan="4" />
<newline />
<field name='user_id' />
<field name='deadline' />
<newline />
<field name='note' colspan="4"/>
<newline />
<field name='category_id'/>
</group>
<separator colspan="4"/>
<group col="2" colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
<button name="make_phonecall" string="Schedule Phone Call" colspan="1" type="object" icon="gtk-execute"/>
</group>
</form>
</field>
</record>
<record id="action_hr_recruitment_phonecall" model="ir.actions.act_window">
<field name="name">Schedule Phone Call</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.recruitment.job2phonecall</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!--<record model="ir.values" id="hr_recruitment_phonecall_values">
<field name="model_id" ref="model_hr_applicant" />
<field name="object" eval="1" />
<field name="name">Schedule Phone Call</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_hr_recruitment_phonecall'))" />
<field name="key">action</field>
<field name="model">hr.applicant</field>
</record>-->
</data>
</openerp>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment