folder rename
This commit is contained in:
75
fusion_plating/fusion_plating_safety/models/hr_employee.py
Normal file
75
fusion_plating/fusion_plating_safety/models/hr_employee.py
Normal file
@@ -0,0 +1,75 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class HrEmployee(models.Model):
|
||||
"""Adds Fusion Plating safety roll-ups to hr.employee.
|
||||
|
||||
Each employee gets reverse links to their training records, exposure
|
||||
monitoring samples and incident records, plus a single boolean that
|
||||
rolls up to True only when every required training course is current.
|
||||
Field names use the x_fc_ prefix per the Fusion Central convention for
|
||||
extensions to base Odoo models.
|
||||
"""
|
||||
_inherit = 'hr.employee'
|
||||
|
||||
x_fc_training_ids = fields.One2many(
|
||||
'fusion.plating.training.record',
|
||||
'employee_id',
|
||||
string='Training Records',
|
||||
)
|
||||
x_fc_training_current = fields.Boolean(
|
||||
string='Training Current',
|
||||
compute='_compute_x_fc_training_current',
|
||||
store=True,
|
||||
help='True when every training record on this employee is currently '
|
||||
'in date (no expired records).',
|
||||
)
|
||||
x_fc_exposure_ids = fields.One2many(
|
||||
'fusion.plating.exposure.monitoring',
|
||||
'employee_id',
|
||||
string='Exposure Samples',
|
||||
)
|
||||
x_fc_incident_ids = fields.One2many(
|
||||
'fusion.plating.incident',
|
||||
'employee_id',
|
||||
string='Incidents',
|
||||
)
|
||||
x_fc_ppe_ids = fields.One2many(
|
||||
'fusion.plating.ppe.issuance',
|
||||
'employee_id',
|
||||
string='PPE Issued',
|
||||
)
|
||||
x_fc_training_count = fields.Integer(
|
||||
compute='_compute_x_fc_safety_counts',
|
||||
)
|
||||
x_fc_exposure_count = fields.Integer(
|
||||
compute='_compute_x_fc_safety_counts',
|
||||
)
|
||||
x_fc_incident_count = fields.Integer(
|
||||
compute='_compute_x_fc_safety_counts',
|
||||
)
|
||||
x_fc_ppe_count = fields.Integer(
|
||||
compute='_compute_x_fc_safety_counts',
|
||||
)
|
||||
|
||||
@api.depends('x_fc_training_ids', 'x_fc_training_ids.state')
|
||||
def _compute_x_fc_training_current(self):
|
||||
for rec in self:
|
||||
if not rec.x_fc_training_ids:
|
||||
rec.x_fc_training_current = True
|
||||
else:
|
||||
rec.x_fc_training_current = not any(
|
||||
t.state == 'expired' for t in rec.x_fc_training_ids
|
||||
)
|
||||
|
||||
def _compute_x_fc_safety_counts(self):
|
||||
for rec in self:
|
||||
rec.x_fc_training_count = len(rec.x_fc_training_ids)
|
||||
rec.x_fc_exposure_count = len(rec.x_fc_exposure_ids)
|
||||
rec.x_fc_incident_count = len(rec.x_fc_incident_ids)
|
||||
rec.x_fc_ppe_count = len(rec.x_fc_ppe_ids)
|
||||
Reference in New Issue
Block a user