93 lines
2.8 KiB
Python
93 lines
2.8 KiB
Python
# -*- 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 FpPpeIssuance(models.Model):
|
|
"""Per-employee Personal Protective Equipment issuance log.
|
|
|
|
Each record captures one issuance of a piece of PPE — respirator,
|
|
gloves, apron, face shield — to an employee, with the size, quantity,
|
|
issue date and the date the equipment is next due for replacement.
|
|
|
|
A historical PPE log demonstrates that the employer is providing
|
|
appropriate protective equipment, which is itself an obligation under
|
|
most occupational health and safety regulations.
|
|
"""
|
|
_name = 'fusion.plating.ppe.issuance'
|
|
_description = 'Fusion Plating — PPE Issuance'
|
|
_inherit = ['mail.thread', 'mail.activity.mixin']
|
|
_order = 'issue_date desc, id desc'
|
|
_rec_name = 'display_name'
|
|
|
|
employee_id = fields.Many2one(
|
|
'hr.employee',
|
|
string='Employee',
|
|
required=True,
|
|
ondelete='cascade',
|
|
tracking=True,
|
|
)
|
|
issue_date = fields.Date(
|
|
string='Issue Date',
|
|
required=True,
|
|
default=fields.Date.context_today,
|
|
tracking=True,
|
|
)
|
|
ppe_type = fields.Selection(
|
|
[
|
|
('respirator', 'Respirator'),
|
|
('gloves', 'Gloves'),
|
|
('apron', 'Apron'),
|
|
('face_shield', 'Face Shield'),
|
|
('safety_glasses', 'Safety Glasses'),
|
|
('boots', 'Boots'),
|
|
('hearing', 'Hearing Protection'),
|
|
('other', 'Other'),
|
|
],
|
|
string='PPE Type',
|
|
required=True,
|
|
default='gloves',
|
|
tracking=True,
|
|
)
|
|
size = fields.Char(
|
|
string='Size',
|
|
)
|
|
quantity = fields.Integer(
|
|
string='Quantity',
|
|
default=1,
|
|
)
|
|
next_replacement = fields.Date(
|
|
string='Next Replacement',
|
|
tracking=True,
|
|
)
|
|
notes = fields.Html(
|
|
string='Notes',
|
|
)
|
|
display_name = fields.Char(
|
|
compute='_compute_display_name',
|
|
store=True,
|
|
)
|
|
company_id = fields.Many2one(
|
|
'res.company',
|
|
related='employee_id.company_id',
|
|
store=True,
|
|
readonly=True,
|
|
)
|
|
active = fields.Boolean(default=True)
|
|
|
|
@api.depends('employee_id', 'ppe_type', 'issue_date')
|
|
def _compute_display_name(self):
|
|
ppe_label = dict(self._fields['ppe_type'].selection)
|
|
for rec in self:
|
|
parts = []
|
|
if rec.employee_id:
|
|
parts.append(rec.employee_id.name)
|
|
if rec.ppe_type:
|
|
parts.append(ppe_label.get(rec.ppe_type, rec.ppe_type))
|
|
if rec.issue_date:
|
|
parts.append(fields.Date.to_string(rec.issue_date))
|
|
rec.display_name = ' — '.join(parts) if parts else 'PPE Issuance'
|