콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

Hallo All.

I have an issue about How to send all attachment file from Module Recruitment to Module Employee.

When i press button (create employee) from module Recruitment, the attachment files that i added in the bottom of Recruitment form(hr.applicant) didn't show up in the bottom of Employee form(hr.employee).

I try this code as another one2many field used to be:

'message_ids': [(6,0,[message.id for message in applicant.message_ids])]

I don't know if fields message_ids are the correct fields that save the attachment files.

Any advice how to send the attachment file?

아바타
취소
베스트 답변

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

아바타
취소
관련 게시물 답글 화면 활동
1
8월 24
1334
0
10월 21
1783
0
3월 25
1242
1
5월 22
2954
1
11월 21
3757