[REF] hr_recruitment: refector code of case_close_with_rmp of hr_recruitment

bzr revid: hmo@tinyerp.com-20111128063318-02c90onrf005yo9t
This commit is contained in:
Harry (OpenERP) 2011-11-28 12:03:18 +05:30
parent 3cba14171c
commit 9c582e04e7
2 changed files with 17 additions and 32 deletions

View File

@ -403,14 +403,6 @@ class hr_applicant(crm.crm_case, osv.osv):
return res
def case_close(self, cr, uid, ids, *args):
"""
@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's Ids
@param *args: Give Tuple Value
"""
employee_obj = self.pool.get('hr.employee')
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
@ -418,29 +410,22 @@ class hr_applicant(crm.crm_case, osv.osv):
return res
def case_close_with_emp(self, cr, uid, ids, *args):
"""
@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's Ids
@param *args: Give Tuple Value
"""
employee_obj = self.pool.get('hr.employee')
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:
self.pool.get('hr.job').write(cr, uid, [applicant.job_id.id], {'no_of_recruitment': applicant.job_id.no_of_recruitment - 1})
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)
hr_employee = self.pool.get('hr.employee')
for applicant in self.browse(cr, uid, ids):
address_id = False
if applicant.partner_id:
address_id = applicant.partner_id.address_get(['contact'])['contact']
if applicant.job_id:
applicant.job_id.write({'no_of_recruitment': applicant.job_id.no_of_recruitment - 1})
emp_id = hr_employee.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
})
self.case_close(cr, uid, [applicant.id], *args)
else:
raise osv.except_osv(_('Warning!'),_('You must define Applied Job for Applicant !'))
return True
def case_reset(self, cr, uid, ids, *args):
"""Resets case as draft

View File

@ -59,7 +59,7 @@
On a successful interview with the applicant, I hired employee.
-
!python {model: hr.applicant}: |
self.case_close(cr, uid, [ref('hr_case_programmer')])
self.case_close_with_emp(cr, uid, [ref('hr_case_programmer')])
-
I check that applicant is "Hired".
-