address_id = self.pool.get('res.partner').address_get(cr,uid,[applicant.partner_id.id],['contact'])['contact']
contact_name = self.pool.get('res.partner').name_get(cr,uid,[applicant.partner_id.id])[0][1]
if applicant.job_id and (applicant.partner_name or contact_name):
- applicant.job_id.write({'no_of_recruitment': applicant.job_id.no_of_recruitment - 1})
+ applicant.job_id.write({'no_of_hired_employee': applicant.job_id.no_of_hired_employee + 1})
emp_id = hr_employee.create(cr,uid,{'name': applicant.partner_name or contact_name,
'job_id': applicant.job_id.id,
'address_home_id': address_id,
_inherit = "hr.job"
_name = "hr.job"
_inherits = {'mail.alias': 'alias_id'}
+
+ def _application_count(self, cr, uid, ids, field_name, arg, context=None):
+ """Calculate total Applications per job"""
+ res = dict.fromkeys(ids, 0)
+ applicant_obj = self.pool.get('hr.applicant')
+ applicant_ids = applicant_obj.search(cr, uid, [('job_id', 'in', ids)], context=context)
+ for applicant in applicant_obj.browse(cr, uid, applicant_ids, context=context):
+ res[applicant.job_id.id] += 1
+ return res
+
_columns = {
'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."),
+ 'application_count': fields.function(_application_count, type='integer', string="Total Applications"),
+ 'manager_id': fields.related('department_id', 'manager_id', type='many2one', string='Department Manager', relation='hr.employee', readonly=True, store=True),
}
def _auto_init(self, cr, context=None):