Hi,
Override the 'Create Employee' Button: Modify the function that is triggered when the "Create Employee" button is pressed. This function should create the new employee record and copy the attachment files from the applicant to the employee.
from odoo import models, fields, api
class HrApplicant(models.Model):
_inherit = 'hr.applicant'
attachment_ids = fields.Many2many('ir.attachment', string='Attachments')
class HrEmployee(models.Model):
_inherit = 'hr.employee'
attachment_ids = fields.Many2many('ir.attachment', string='Attachments')
@api.model
def create_employee_from_applicant(self, applicant_id):
# Create a new employee record based on the applicant data
applicant = self.env['hr.applicant'].browse(applicant_id)
employee_data = {
'name': applicant.name,
# Add other relevant fields from applicant to employee
# ...
# Copy the attachments from applicant to employee
'attachment_ids': [(6, 0, applicant.attachment_ids.ids)],
}
new_employee = self.create(employee_data)
return new_employee.id
once you can use this override method, otherwise you can super the create_employee_from_applicant function, and update the employee_data dictionary
i.e.
employee_data.update({" 'default_attachment_ids': [(6, 0, applicant.attachment_ids.ids)]})
Regards