94 lines
2.9 KiB
Python
94 lines
2.9 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 FpCalibrationEvent(models.Model):
|
|
"""A single calibration event against a piece of equipment.
|
|
|
|
Captures who calibrated it, the result (pass / limited / fail), the
|
|
as-found and as-left readings, and the certificate reference. A failed
|
|
calibration carries an impact_assessment field so the QM can document
|
|
which jobs may have been measured by an out-of-tolerance instrument.
|
|
"""
|
|
_name = 'fusion.plating.calibration.event'
|
|
_description = 'Fusion Plating — Calibration Event'
|
|
_inherit = ['mail.thread', 'mail.activity.mixin']
|
|
_order = 'cal_date desc, id desc'
|
|
_rec_name = 'display_name'
|
|
|
|
equipment_id = fields.Many2one(
|
|
'fusion.plating.calibration.equipment',
|
|
string='Equipment',
|
|
required=True,
|
|
ondelete='cascade',
|
|
tracking=True,
|
|
)
|
|
display_name = fields.Char(
|
|
compute='_compute_display_name',
|
|
store=True,
|
|
)
|
|
cal_date = fields.Date(
|
|
string='Calibration Date',
|
|
required=True,
|
|
default=lambda self: fields.Date.context_today(self),
|
|
tracking=True,
|
|
)
|
|
performed_by_id = fields.Many2one(
|
|
'res.users',
|
|
string='Performed By',
|
|
default=lambda self: self.env.user,
|
|
tracking=True,
|
|
)
|
|
performed_by_external = fields.Char(
|
|
string='External Calibration House',
|
|
help='If calibrated by an outside lab, name them here.',
|
|
)
|
|
result = fields.Selection(
|
|
[
|
|
('pass', 'Pass'),
|
|
('limited', 'Pass with Limitations'),
|
|
('fail', 'Fail'),
|
|
],
|
|
string='Result',
|
|
required=True,
|
|
default='pass',
|
|
tracking=True,
|
|
)
|
|
as_found_notes = fields.Text(
|
|
string='As-Found Readings',
|
|
)
|
|
as_left_notes = fields.Text(
|
|
string='As-Left Readings',
|
|
)
|
|
certificate_ref = fields.Char(
|
|
string='Certificate #',
|
|
)
|
|
impact_assessment = fields.Html(
|
|
string='Impact Assessment',
|
|
help='If the result is Fail or Limited, document which jobs / parts '
|
|
'were measured by this instrument since the last calibration.',
|
|
)
|
|
facility_id = fields.Many2one(
|
|
related='equipment_id.facility_id',
|
|
store=True,
|
|
readonly=True,
|
|
)
|
|
company_id = fields.Many2one(
|
|
'res.company',
|
|
related='equipment_id.company_id',
|
|
store=True,
|
|
readonly=True,
|
|
)
|
|
|
|
@api.depends('equipment_id.code', 'cal_date')
|
|
def _compute_display_name(self):
|
|
for rec in self:
|
|
if rec.equipment_id and rec.cal_date:
|
|
rec.display_name = f'{rec.equipment_id.code} — {rec.cal_date}'
|
|
else:
|
|
rec.display_name = 'Calibration Event'
|