54 lines
2.5 KiB
Python
54 lines
2.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2026 Nexa Systems Inc.
|
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
|
from odoo import api, fields, models
|
|
|
|
from odoo.addons.fusion_plating.models._fp_uom_selection import FP_UOM_SELECTION
|
|
|
|
|
|
class FpSpillRegister(models.Model):
|
|
_name = 'fusion.plating.spill.register'
|
|
_description = 'Fusion Plating - Spill Register'
|
|
_inherit = ['mail.thread', 'mail.activity.mixin']
|
|
_order = 'spill_date desc, id desc'
|
|
|
|
name = fields.Char(string='Reference', required=True, copy=False, default=lambda s: s._default_name(), tracking=True)
|
|
facility_id = fields.Many2one('fusion.plating.facility', string='Facility', required=True, ondelete='restrict', tracking=True)
|
|
company_id = fields.Many2one('res.company', related='facility_id.company_id', store=True, readonly=True)
|
|
spill_date = fields.Datetime(string='Spill Date', required=True, default=fields.Datetime.now, tracking=True)
|
|
reported_by_id = fields.Many2one('res.users', string='Reported By', default=lambda s: s.env.user)
|
|
substance = fields.Char(string='Substance', tracking=True)
|
|
quantity = fields.Float(string='Quantity', digits=(16, 3),
|
|
help='Quantity spilled, expressed in the unit selected below.')
|
|
uom = fields.Selection(FP_UOM_SELECTION, string='UoM', default='l',
|
|
help='Unit of the spill quantity (L for liquids, kg for solids).')
|
|
location = fields.Char(string='Location')
|
|
containment_action = fields.Text(string='Containment Action')
|
|
regulator_notified = fields.Boolean(string='Regulator Notified', tracking=True)
|
|
regulator_notification_date = fields.Datetime(string='Notification Sent')
|
|
root_cause = fields.Text(string='Root Cause')
|
|
corrective_action = fields.Text(string='Corrective Action')
|
|
capa_ref = fields.Char(string='CAPA Reference')
|
|
state = fields.Selection(
|
|
[('reported', 'Reported'), ('contained', 'Contained'),
|
|
('investigation', 'Investigation'), ('closed', 'Closed')],
|
|
string='Status', default='reported', required=True, tracking=True,
|
|
)
|
|
attachment_ids = fields.Many2many(
|
|
'ir.attachment', 'fp_spill_register_attachment_rel', 'spill_id', 'attachment_id', string='Attachments',
|
|
)
|
|
|
|
@api.model
|
|
def _default_name(self):
|
|
seq = self.env['ir.sequence'].next_by_code('fusion.plating.spill.register')
|
|
return seq or '/'
|
|
|
|
def action_contain(self):
|
|
self.write({'state': 'contained'})
|
|
|
|
def action_investigate(self):
|
|
self.write({'state': 'investigation'})
|
|
|
|
def action_close(self):
|
|
self.write({'state': 'closed'})
|