From 4d1905fa5eecd0c9cc8c2550e76d4c44453c04de Mon Sep 17 00:00:00 2001 From: ggh-openerp Date: Tue, 2 Apr 2013 12:20:52 +0530 Subject: [PATCH] [IMP] Recruitment: count applicant priority ratio in job position bzr revid: ggh@tinyerp.com-20130402065052-ghvng16dau69dpca --- addons/hr_recruitment/hr_recruitment.py | 27 ++++++++++++++++--- addons/hr_recruitment/hr_recruitment_menu.xml | 2 +- addons/hr_recruitment/hr_recruitment_view.xml | 24 ++++++++++++++--- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 8cde174f746..2477bc18f78 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -492,15 +492,36 @@ class hr_job(osv.osv): _inherit = "hr.job" _name = "hr.job" _inherits = {'mail.alias': 'alias_id'} + + def _count_priority(self, cr, uid, ids, name, args, context=None): + res = {} + for position in self.browse(cr, uid,ids, context=context): + res[position.id] = {} + priority1 = 0 + priority2 = 0 + priority3 = 0 + applicant_obj = self.pool.get('hr.applicant') + a_ids = applicant_obj.search(cr, uid, [('job_id', '=', position.id)], context=context) + for applicant in self.pool.get('hr.applicant').browse(cr, uid, a_ids, context=context): + if applicant.job_id.id == position.id: + if applicant.priority == '3': + priority1 += 1 + elif applicant.priority == '2': + priority2 += 1 + elif applicant.priority == '1': + priority3 += 1 + else: + pass + res[position.id] = {'priority1': priority1, 'priority2': priority2, 'priority3': priority3} + return res + _columns = { - 'name': fields.char('Job Name', size=128, required=True, select=True), - 'no_of_recruitment': fields.float('Expected in Recruitment', help='Number of new employees you expect to recruit.'), - 'department_id': fields.many2one('hr.department', 'Department'), 'color': fields.integer('Color Index'), 'survey_id': fields.many2one('survey', 'Interview Form', help="Choose an interview form for this job position and you will be able to print/answer this interview from all applicants who apply for this job"), 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True, help="Email alias for this job position. New emails will automatically " "create new applicants for this job position."), + 'priority_count': fields.function(_count_priority, string='Total Priority Employees', type="char"), } _defaults = { 'alias_domain': False, # always hide alias during creation diff --git a/addons/hr_recruitment/hr_recruitment_menu.xml b/addons/hr_recruitment/hr_recruitment_menu.xml index e5e170f4b35..009a03289a1 100644 --- a/addons/hr_recruitment/hr_recruitment_menu.xml +++ b/addons/hr_recruitment/hr_recruitment_menu.xml @@ -66,7 +66,7 @@ parent="base.menu_crm_case_job_req_main" id="menu_crm_case_categ0_act_job" action="crm_case_categ0_act_job" sequence="1"/> - + diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 75f63ca97dd..952cc9e55be 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -331,6 +331,7 @@ +
@@ -344,11 +345,26 @@

+
+ Employees +
- + + + + + +
+ + + + +
+ + + +
-
- Employees
@@ -359,7 +375,7 @@ - + Job Positions hr.job form