70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
from odoo import fields, models
|
|
|
|
|
|
class EmployeeBridgeRequestedAttachment(models.Model):
|
|
_name = "employee.bridge.requested.attachment"
|
|
_description = "Onboarding Requested Attachment"
|
|
|
|
name = fields.Char(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")
|
|
|
|
|
|
class EmployeeBridgeAttachment(models.Model):
|
|
_name = "employee.bridge.attachment"
|
|
_description = "Onboarding Attachment"
|
|
_rec_name = "name"
|
|
|
|
name = fields.Char(required=True)
|
|
bridge_id = fields.Many2one("recruitment.employee.bridge", required=True, ondelete="cascade")
|
|
employee_id = fields.Many2one("hr.employee")
|
|
requested_attachment_id = fields.Many2one("employee.bridge.requested.attachment")
|
|
attachment_type = fields.Selection(related="requested_attachment_id.attachment_type")
|
|
file = fields.Binary(required=True)
|
|
file_name = fields.Char()
|
|
review_status = fields.Selection([
|
|
("draft", "Under Review"),
|
|
("pass", "PASS"),
|
|
("fail", "FAIL"),
|
|
], default="draft")
|
|
review_comments = fields.Char()
|
|
|
|
def action_preview_file(self):
|
|
self.ensure_one()
|
|
attachment = self.env["ir.attachment"].sudo().create({
|
|
"name": self.file_name or self.name,
|
|
"datas": self.file,
|
|
"res_model": self._name,
|
|
"res_id": self.id,
|
|
"type": "binary",
|
|
})
|
|
return {
|
|
"name": "File Preview",
|
|
"type": "ir.actions.act_url",
|
|
"url": f"/web/content/{attachment.id}?download=false",
|
|
"target": "current",
|
|
}
|
|
|
|
|
|
class FamilyDetails(models.Model):
|
|
_inherit = "family.details"
|
|
|
|
bridge_id = fields.Many2one("recruitment.employee.bridge", ondelete="cascade")
|
|
|
|
|
|
class EducationHistory(models.Model):
|
|
_inherit = "education.history"
|
|
|
|
bridge_id = fields.Many2one("recruitment.employee.bridge", ondelete="cascade")
|
|
|
|
|
|
class EmployerHistory(models.Model):
|
|
_inherit = "employer.history"
|
|
|
|
bridge_id = fields.Many2one("recruitment.employee.bridge", ondelete="cascade")
|