39 lines
1.7 KiB
Python
39 lines
1.7 KiB
Python
from odoo import models, fields, api
|
|
|
|
class RecruitmentAttachments(models.Model):
|
|
_name = 'recruitment.attachments'
|
|
_description = 'Recruitment Attachments'
|
|
|
|
name = fields.Char(string='Name', required=True)
|
|
attachment_type = fields.Selection([('personal','Personal Documents'),('education','Education Documents'),('previous_employer','Previous Employer'),('others','Others')],default="others",required=True)
|
|
is_default = fields.Boolean(string='Is Default')
|
|
|
|
employee_recruitment_attachments = fields.One2many('employee.recruitment.attachments','recruitment_attachment_id',string="Documents")
|
|
|
|
|
|
class EmployeeRecruitmentAttachments(models.Model):
|
|
_name = "employee.recruitment.attachments"
|
|
_rec_name = 'name'
|
|
|
|
name = fields.Char(string='Attachment Name', required=True)
|
|
employee_id = fields.Many2one('hr.employee')
|
|
applicant_id = fields.Many2one('hr.applicant')
|
|
candidate_id = fields.Many2one('hr.candidate')
|
|
recruitment_attachment_id = fields.Many2one('recruitment.attachments')
|
|
recruitment_attachment_type = fields.Selection([('personal','Personal Documents'),('education','Education Documents'),('previous_employer','Previous Employer'),('others','Others')],related='recruitment_attachment_id.attachment_type')
|
|
file = fields.Binary(string='File', required=True)
|
|
|
|
|
|
|
|
@api.model
|
|
def create(self, vals):
|
|
# Auto-link applicant_id if context is passed correctly
|
|
if self.env.context.get('default_applicant_id'):
|
|
vals['applicant_id'] = self.env.context['default_applicant_id']
|
|
return super().create(vals)
|
|
|
|
class Employee(models.Model):
|
|
_inherit='hr.employee'
|
|
|
|
employee_attachment_ids = fields.One2many('employee.recruitment.attachments','employee_id',string="Attachments")
|