[IMP]Improve code for interview link and add field no_of_application in job position form

bzr revid: vja@tinyerp.com-20130509092252-e26nsd25vwugrtrw
This commit is contained in:
Vishmita Jadeja (openerp) 2013-05-09 14:52:52 +05:30
parent 866c2b4236
commit 50082c1160
4 changed files with 33 additions and 29 deletions

View File

@ -74,11 +74,14 @@ class hr_job(osv.osv):
def _no_of_employee(self, cr, uid, ids, name, args, context=None):
res = {}
applicant_obj = self.pool.get('hr.applicant')
for job in self.browse(cr, uid, ids, context=context):
nb_employees = len(job.employee_ids or [])
job_ids = len(applicant_obj.search(cr, uid, [('job_id', '=', job.id)], context=context))
res[job.id] = {
'no_of_employee': nb_employees,
'expected_employees': nb_employees + job.no_of_recruitment,
'no_of_application':job_ids
}
return res
@ -105,6 +108,9 @@ class hr_job(osv.osv):
'hr.employee': (_get_job_position, ['job_id'], 10),
},
multi='no_of_employee'),
'no_of_application': fields.function(_no_of_employee, type="integer" ,string='Total Number of Application',
help='Expected number of employees for this job position after new recruitment.',
multi='no_of_employee'),
'no_of_employee': fields.function(_no_of_employee, string="Current Number of Employees",
help='Number of employees currently occupying this job position.',
store = {

View File

@ -492,30 +492,6 @@ class hr_job(osv.osv):
_name = "hr.job"
_inherits = {'mail.alias': 'alias_id'}
def _count_priority(self, cr, uid, ids, name, args, context=None):
"""Applicant, priority count like number of star 3,2,1(star rating)
"""
applicant_obj = self.pool.get('hr.applicant')
res = {}
for position in self.browse(cr, uid, ids, context=context):
res[position.id] = {}
priority1 = 0
priority2 = 0
priority3 = 0
rate_ids = applicant_obj.search(cr, uid, [('job_id', '=', position.id)], context=context)
for applicant in applicant_obj.browse(cr, uid, rate_ids, context=context):
if applicant.job_id.id == position.id:
if applicant.priority == '3':
priority3 += 1
elif applicant.priority == '2':
priority2 += 1
elif applicant.priority == '1':
priority1 += 1
else:
pass
res[position.id] = {'priority1': priority1, 'priority2': priority2, 'priority3': priority3, 'total_application':len(rate_ids)}
return res
def _get_department_mgr(self, cr, uid, ids, name, args, context=None):
"""Get manager image for specific job position.
"""
@ -535,7 +511,6 @@ class hr_job(osv.osv):
'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"),
'manager_id': fields.function(_get_department_mgr, string='Department Manager', type="char"),#manager image in kanban
}
_defaults = {

View File

@ -303,10 +303,12 @@
<field name="inherit_id" ref="hr.view_hr_job_form"/>
<field name="arch" type="xml">
<field name="expected_employees" version="7.0" position="after">
<label for="no_of_application" groups="base.group_user"/>
<div><field name="no_of_application"/><button class="oe_inline oe_link oe_app" string="Application" name="%(hr_job_applications)d" type="action"/></div>
<label for="survey_id" groups="base.group_user"/>
<div groups="base.group_user">
<field name="survey_id" class="oe_inline" domain="[('type','=','Human Resources')]"/>
<button class="oe_inline"
<button class="oe_inline oe_link"
string="Interview"
name="action_print_survey" type="object"
attrs="{'invisible':[('survey_id','=',False)]}"/>
@ -344,7 +346,7 @@
<field name="department_id"/>
<field name="no_of_recruitment"/>
<field name="color"/>
<field name="priority_count"/>
<field name="no_of_application"/>
<field name="manager_id"/>
<field name="message_summary"/>
<templates>
@ -359,6 +361,7 @@
</ul>
</div>
<div class="oe_kanban_content" >
<a class="oe_kanban_action_a" name="%(hr_job_applications)d" type="action" >
<h3 class="oe_job oe_kanban_ellipsis"><field name="name"/></h3>
<div class="oe_job oe_kanban_ellipsis"><field name="department_id"/></div>
@ -366,8 +369,8 @@
<div class="oe_name"><t t-esc="record.manager_id.value.name"/></div>
<div style="margin-top:25px;margin-bottom:7px;"><t t-esc="Math.round(record.no_of_recruitment.raw_value)"/> Expected in Recruitment</div>
<div class="oe_application">
<span t-if="widget.values.priority_count.value.total_application gt 1"><t t-esc="Math.round(widget.values.priority_count.value.total_application)"/> Applications</span>
<span t-if="widget.values.priority_count.value.total_application lt 2"><t t-esc="Math.round(widget.values.priority_count.value.total_application)"/> Application</span>
<span t-if="widget.values.no_of_application.value gt 1"><t t-esc="widget.values.no_of_application.value"/> Applications</span>
<span t-if="widget.values.no_of_application.value lt 2"><t t-esc="widget.values.no_of_application.value"/> Application</span>
</div>
</a>
<div class="oe_kanban_footer_left oe_job_message"><t t-raw="record.message_summary.raw_value"/></div>
@ -385,6 +388,20 @@
<field name="res_model">hr.job</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to define a new job position.
</p><p>
Job Positions are used to define jobs and their requirements.
You can keep track of the number of employees you have per job
position and follow the evolution according to what you planned
for the future.
</p><p>
You can attach a survey to a job position. It will be used in
the recruitment process to evaluate the applicants for this job
position.
</p>
</field>
</record>
<!-- Stage Tree View -->

View File

@ -32,3 +32,9 @@
font-size: 11px;
color: gray;
}
.openerp .oe_app{
position: absolute;
margin-top: -18px !important;
margin-left: 16px !important;
}