odoo18/addons_extensions/hr_recruitment_extended/models/hr_applicant.py

27 lines
875 B
Python

from odoo import models, fields, api, _
class HRApplicant(models.Model):
_inherit = 'hr.applicant'
refused_state = fields.Many2one('hr.recruitment.stage', readonly=True, force_save=True)
def reset_applicant(self):
""" Reinsert the applicant into the recruitment pipe in the first stage"""
res = super(HRApplicant, self).reset_applicant()
for applicant in self:
applicant.write(
{'refused_state': False})
return res
class ApplicantGetRefuseReason(models.TransientModel):
_inherit = 'applicant.get.refuse.reason'
def action_refuse_reason_apply(self):
res = super(ApplicantGetRefuseReason, self).action_refuse_reason_apply()
refused_applications = self.applicant_ids
refused_applications.write({'refused_state': refused_applications.stage_id.id})
return res