folder rename
This commit is contained in:
142
fusion_plating/fusion_plating_safety/models/fp_incident.py
Normal file
142
fusion_plating/fusion_plating_safety/models/fp_incident.py
Normal file
@@ -0,0 +1,142 @@
|
||||
# -*- 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 FpIncident(models.Model):
|
||||
"""A safety incident, near-miss, or environmental event.
|
||||
|
||||
The incident register is the central log of anything that did, or
|
||||
almost did, harm a worker or the environment. Each record walks
|
||||
through draft → investigation → closed and captures who was hurt,
|
||||
where, what happened, the immediate response, the investigation
|
||||
findings, the root cause and the corrective action.
|
||||
|
||||
For Ontario operations the WSIB Form 7 fields flag whether the
|
||||
incident is reportable to the Workplace Safety and Insurance Board
|
||||
and whether the form has actually been filed.
|
||||
"""
|
||||
_name = 'fusion.plating.incident'
|
||||
_description = 'Fusion Plating — Incident'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_order = 'incident_date desc, id desc'
|
||||
_rec_name = 'name'
|
||||
|
||||
name = fields.Char(
|
||||
string='Reference',
|
||||
required=True,
|
||||
copy=False,
|
||||
readonly=True,
|
||||
default=lambda self: self._default_name(),
|
||||
tracking=True,
|
||||
)
|
||||
incident_date = fields.Datetime(
|
||||
string='Incident Date',
|
||||
required=True,
|
||||
default=fields.Datetime.now,
|
||||
tracking=True,
|
||||
)
|
||||
facility_id = fields.Many2one(
|
||||
'fusion.plating.facility',
|
||||
string='Facility',
|
||||
tracking=True,
|
||||
)
|
||||
reported_by_id = fields.Many2one(
|
||||
'res.users',
|
||||
string='Reported By',
|
||||
default=lambda self: self.env.user,
|
||||
tracking=True,
|
||||
)
|
||||
incident_type = fields.Selection(
|
||||
[
|
||||
('injury', 'Injury'),
|
||||
('near_miss', 'Near Miss'),
|
||||
('first_aid', 'First Aid'),
|
||||
('lost_time', 'Lost Time'),
|
||||
('medical', 'Medical'),
|
||||
('property_damage', 'Property Damage'),
|
||||
('environmental', 'Environmental'),
|
||||
('other', 'Other'),
|
||||
],
|
||||
string='Type',
|
||||
default='near_miss',
|
||||
required=True,
|
||||
tracking=True,
|
||||
)
|
||||
employee_id = fields.Many2one(
|
||||
'hr.employee',
|
||||
string='Employee Involved',
|
||||
ondelete='set null',
|
||||
tracking=True,
|
||||
)
|
||||
location = fields.Char(
|
||||
string='Location',
|
||||
tracking=True,
|
||||
)
|
||||
description = fields.Html(
|
||||
string='Description',
|
||||
)
|
||||
immediate_action = fields.Html(
|
||||
string='Immediate Action',
|
||||
)
|
||||
investigation = fields.Html(
|
||||
string='Investigation',
|
||||
)
|
||||
root_cause = fields.Html(
|
||||
string='Root Cause',
|
||||
)
|
||||
corrective_action = fields.Html(
|
||||
string='Corrective Action',
|
||||
)
|
||||
wsib_reportable = fields.Boolean(
|
||||
string='WSIB Reportable',
|
||||
tracking=True,
|
||||
)
|
||||
wsib_form_7_submitted = fields.Boolean(
|
||||
string='WSIB Form 7 Submitted',
|
||||
tracking=True,
|
||||
)
|
||||
lost_time_days = fields.Integer(
|
||||
string='Lost-Time Days',
|
||||
tracking=True,
|
||||
)
|
||||
state = fields.Selection(
|
||||
[
|
||||
('draft', 'Draft'),
|
||||
('investigation', 'Investigation'),
|
||||
('closed', 'Closed'),
|
||||
],
|
||||
string='Status',
|
||||
default='draft',
|
||||
required=True,
|
||||
tracking=True,
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
'res.company',
|
||||
string='Company',
|
||||
default=lambda self: self.env.company,
|
||||
)
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
# ==========================================================================
|
||||
# Defaults
|
||||
# ==========================================================================
|
||||
@api.model
|
||||
def _default_name(self):
|
||||
seq = self.env['ir.sequence'].next_by_code('fusion.plating.incident')
|
||||
return seq or '/'
|
||||
|
||||
# ==========================================================================
|
||||
# Actions
|
||||
# ==========================================================================
|
||||
def action_start_investigation(self):
|
||||
self.write({'state': 'investigation'})
|
||||
|
||||
def action_close(self):
|
||||
self.write({'state': 'closed'})
|
||||
|
||||
def action_reopen(self):
|
||||
self.write({'state': 'draft'})
|
||||
Reference in New Issue
Block a user