From 2be7bebe871ecd0cf14f34ddab8869ddb95176ab Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Fri, 11 Mar 2011 15:37:52 +0530 Subject: [PATCH] [IMP]: hr_recruitment: Improvement in wizard to hire applicant * Put appripriate function names * Improved view bzr revid: rpa@tinyerp.com-20110311100752-ltcri0xmbn89ic30 --- addons/hr_recruitment/hr_recruitment.py | 36 ++++++++----------- .../wizard/hr_recruitment_employee_hired.py | 11 ++---- .../wizard/hr_recruitment_employee_hired.xml | 13 +++---- 3 files changed, 23 insertions(+), 37 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 4cd6b84c22e..a99a105a3ca 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -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 diff --git a/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.py b/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.py index bcb5a5c2507..d11a1f16775 100644 --- a/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.py +++ b/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.py @@ -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() diff --git a/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.xml b/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.xml index b447782719a..7a66d070291 100644 --- a/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.xml +++ b/addons/hr_recruitment/wizard/hr_recruitment_employee_hired.xml @@ -8,15 +8,12 @@ form
- - + -