58 lines
3.0 KiB
Python
58 lines
3.0 KiB
Python
from odoo import models, fields, api, _
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
|
|
class RecruitmentRequisition(models.Model):
|
|
_inherit = 'recruitment.requisition'
|
|
|
|
hr_job_recruitment = fields.Many2one('hr.job.recruitment', tracking=True)
|
|
position_title = fields.Char(string="Position Title", required=False,related='job_id.name')
|
|
job_category = fields.Many2one('job.category', tracking=True)
|
|
job_priority = fields.Selection([
|
|
('low', 'Low'),
|
|
('medium', 'Medium'),
|
|
('high', 'High')
|
|
], string='Priority', tracking=True)
|
|
experience = fields.Many2one('candidate.experience', string="Experience", tracking=True)
|
|
recruitment_status = fields.Selection([('open','Open'),('closed','Closed'),('hold','Hold'),('modified','Modified'),('cancelled','Cancelled')],related='hr_job_recruitment.recruitment_status',readonly=False, tracking=True)
|
|
|
|
@api.onchange('recruitment_status')
|
|
def _onchange_recruitment_status(self):
|
|
for rec in self:
|
|
if rec.recruitment_status != 'open':
|
|
rec.hr_job_recruitment.website_published = False
|
|
|
|
@api.onchange('assign_to')
|
|
def onchange_assign_to(self):
|
|
for rec in self:
|
|
if rec.hr_job_recruitment and rec.state == 'jd_created':
|
|
rec.hr_job_recruitment.user_id = rec.assign_to.id
|
|
|
|
def action_final_approve(self):
|
|
res = super().action_final_approve()
|
|
for rec in self:
|
|
if not rec.hr_job_recruitment:
|
|
rec.hr_job_recruitment = self.env['hr.job.recruitment'].create({
|
|
'job_id': rec.job_id.id if rec.job_id else False,
|
|
'job_category': rec.job_category.id if rec.job_category else False,
|
|
'no_of_recruitment': rec.number_of_positions,
|
|
'description': rec.job_description,
|
|
'skill_ids': [(6, 0, rec.primary_skill_ids.ids)],
|
|
'secondary_skill_ids': [(6, 0, rec.secondary_skill_ids.ids)],
|
|
'requested_by': rec.requested_by.partner_id.id if rec.recruitment_type == 'internal' else rec.client_id.id,
|
|
'recruitment_type': rec.recruitment_type,
|
|
'contract_type_id': rec.contract_type_id.id if rec.contract_type_id else False,
|
|
'address_id': rec.client_id.id if rec.client_id.company_type == 'company' else (rec.client_id.parent_id.id if rec.client_id.parent_id else False),
|
|
'user_id': rec.assign_to.id,
|
|
'address_id': rec.requested_by.company_id.partner_id.id if rec.requested_by.company_id else '',
|
|
'job_priority': rec.job_priority,
|
|
'experience': rec.experience.id if rec.experience else False,
|
|
'budget':rec.budget,
|
|
'target_from': rec.target_startdate if rec.target_startdate else fields.Date.today(),
|
|
'target_to': rec.target_deadline if rec.target_deadline else False,
|
|
})
|
|
|
|
return res
|
|
|