[IMP]: hr_recruitment: Improvement in wizard to hire applicant

* Put appripriate function names
* Improved view

bzr revid: rpa@tinyerp.com-20110311100752-ltcri0xmbn89ic30
This commit is contained in:
Rucha (Open ERP) 2011-03-11 15:37:52 +05:30
parent d64d4b0d83
commit 2be7bebe87
3 changed files with 23 additions and 37 deletions

View File

@ -414,27 +414,13 @@ class hr_applicant(crm.crm_case, osv.osv):
@param *args: Give Tuple Value
"""
employee_obj = self.pool.get('hr.employee')
job_obj = self.pool.get('hr.job')
partner_obj = self.pool.get('res.partner')
address_id = False
res = super(hr_applicant, self).case_close(cr, uid, ids, *args)
for (id, name) in self.name_get(cr, uid, ids):
message = _("Applicant '%s' is being hired.") % name
self.log(cr, uid, id, message)
applicant = self.browse(cr, uid, ids)[0]
if applicant.partner_id:
address_id = partner_obj.address_get(cr, uid, [applicant.partner_id.id], ['contact'])['contact']
if applicant.job_id:
emp_id = employee_obj.create(cr,uid,{'name': applicant.partner_name or applicant.name,
'job_id': applicant.job_id.id,
'address_home_id':address_id,
'department_id':applicant.department_id.id
})
else:
raise osv.except_osv(_('Warning!'),_('You must define job Id for Applicant !'))
return res
def case_close_without_emp(self, cr, uid, ids, *args):
def case_close_with_emp(self, cr, uid, ids, *args):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@ -443,12 +429,20 @@ class hr_applicant(crm.crm_case, osv.osv):
@param *args: Give Tuple Value
"""
employee_obj = self.pool.get('hr.employee')
job_obj = self.pool.get('hr.job')
res = super(hr_applicant, self).case_close(cr, uid, ids, *args)
for (id, name) in self.name_get(cr, uid, ids):
message = _("Applicant '%s' is being hired.") % name
self.log(cr, uid, id, message)
return res
partner_obj = self.pool.get('res.partner')
address_id = False
applicant = self.browse(cr, uid, ids)[0]
if applicant.partner_id:
address_id = partner_obj.address_get(cr, uid, [applicant.partner_id.id], ['contact'])['contact']
if applicant.job_id:
emp_id = employee_obj.create(cr,uid,{'name': applicant.partner_name or applicant.name,
'job_id': applicant.job_id.id,
'address_home_id': address_id,
'department_id': applicant.department_id.id
})
else:
raise osv.except_osv(_('Warning!'),_('You must define Applied Job for Applicant !'))
return self.case_close(cr, uid, ids, *args)
def case_reset(self, cr, uid, ids, *args):
"""Resets case as draft

View File

@ -36,12 +36,10 @@ class hired_employee(osv.osv_memory):
"""
if context is None:
context = {}
hr_app = self.pool.get('hr.applicant')
hr_app.case_close(cr, uid,context.get('active_ids',False))
self.pool.get('hr.applicant').case_close(cr, uid,context.get('active_ids',[]))
return {}
def case_close_without_emp(self, cr, uid,ids, context=None):
def case_close_with_emp(self, cr, uid,ids, context=None):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@ -50,10 +48,7 @@ class hired_employee(osv.osv_memory):
"""
if context is None:
context = {}
hr_app = self.pool.get('hr.applicant')
hr_app.case_close_without_emp(cr, uid,context.get('active_ids',False))
self.pool.get('hr.applicant').case_close_with_emp(cr, uid,context.get('active_ids', []))
return {}
hired_employee()

View File

@ -8,15 +8,12 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create New Employee">
<group col="4" colspan="6">
<separator string="Would you like to create an employee ?" colspan="4" />
<label string="Would you like to create an employee ?" colspan="4" />
<separator string="" colspan="4"/>
<newline />
</group>
<group col="3" colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
<button name="case_close_without_emp" string="No" icon='gtk-no' type="object"/>
<button name="case_close" string="Yes" colspan="1" type="object" icon="terp-camera_test"/>
</group>
<button name="case_close" string="No" icon='gtk-no' type="object"/>
<button name="case_close_with_emp" string="Yes" colspan="1" type="object" icon="terp-camera_test"/>
</form>
</field>
</record>
@ -30,4 +27,4 @@
</record>
</data>
</openerp>
</openerp>