[FIX] hr_recruitment{,_skills} : employee creation fix
If an applicant goes through the salary configurator to create his contract, the employee created will not get the associated sign requests nor the skills as it is working now when creating an employee from the "create employee" button on the applicant page. Also fixes: - a traceback obtained on the salary configurator when having hr_contract_salary installed and not hr_work_entry_contract - a traceback obtained while trying to access an applicant form while in debug mode task-3002185 closes odoo/odoo#104320 X-original-commit: 20d5de3490baaab62715fe0f4f2a9a48dc248d55 Related: odoo/enterprise#33332 Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
@@ -430,6 +430,8 @@ class Applicant(models.Model):
|
||||
interviewers_to_clean = old_interviewers - self.interviewer_ids
|
||||
interviewers_to_clean._remove_recruitment_interviewers()
|
||||
self.sudo().interviewer_ids._create_recruitment_interviewers()
|
||||
if vals.get('emp_id'):
|
||||
self._update_employee_from_applicant()
|
||||
return res
|
||||
|
||||
def get_empty_list_help(self, help):
|
||||
@@ -675,6 +677,10 @@ class Applicant(models.Model):
|
||||
dict_act_window['context'] = employee_data
|
||||
return dict_act_window
|
||||
|
||||
def _update_employee_from_applicant(self):
|
||||
# This method is to be overriden
|
||||
return
|
||||
|
||||
def archive_applicant(self):
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
|
||||
@@ -32,3 +32,17 @@ class HrApplicant(models.Model):
|
||||
'skill_type_id': applicant_skill.skill_type_id.id,
|
||||
}) for applicant_skill in self.applicant_skill_ids]
|
||||
return action
|
||||
|
||||
def _update_employee_from_applicant(self):
|
||||
vals_list = []
|
||||
for applicant in self:
|
||||
existing_skills = applicant.emp_id.employee_skill_ids.skill_id
|
||||
skills_to_create = applicant.applicant_skill_ids.skill_id - existing_skills
|
||||
vals_list.extend([{
|
||||
'employee_id': applicant.emp_id.id,
|
||||
'skill_id': skill.id,
|
||||
'skill_level_id': applicant.applicant_skill_ids.filtered(lambda s: s.skill_id == skill).skill_level_id.id,
|
||||
'skill_type_id': skill.skill_type_id.id,
|
||||
} for skill in skills_to_create])
|
||||
self.env['hr.employee.skill'].create(vals_list)
|
||||
return super()._update_employee_from_applicant()
|
||||
|
||||
Reference in New Issue
Block a user