diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 931600fef9f..60657e9ff85 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -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 user’s 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 user’s 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 diff --git a/addons/hr_recruitment/test/recruitment_process.yml b/addons/hr_recruitment/test/recruitment_process.yml index 33232ab0f2f..43575137a6e 100644 --- a/addons/hr_recruitment/test/recruitment_process.yml +++ b/addons/hr_recruitment/test/recruitment_process.yml @@ -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". -