Files
Odoo-Modules/fusion_plating/fusion_plating_certificates/models/fp_thickness_reading.py
gsinghpal d9f58b9851 changes
2026-04-26 15:05:17 -04:00

78 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 FpThicknessReading(models.Model):
"""Fischerscope thickness measurement data.
Captures individual XRF readings from equipment like the
Fischerscope XDAL 600. Linked to certificates and/or MOs.
Data is manually entered for now; future: CSV import from equipment.
"""
_name = 'fp.thickness.reading'
_description = 'Fusion Plating — Thickness Reading'
_order = 'reading_number'
certificate_id = fields.Many2one(
'fp.certificate', string='Certificate', ondelete='cascade',
)
# Phase 6 (Sub 11) — production_id retired (MRP module gone).
# Thickness readings link via certificate_id and quality_check_id.
reading_number = fields.Integer(
string='Reading #', default=1, help='Sequence number (n=1, n=2, n=3).',
)
nip_mils = fields.Float(
string='NiP (mils)', digits=(10, 4), help='NiP thickness in mils.',
)
ni_percent = fields.Float(
string='Ni %', digits=(6, 3), help='Nickel content percentage.',
)
p_percent = fields.Float(
string='P %', digits=(6, 4), help='Phosphorus content percentage.',
)
position_label = fields.Char(
string='Position', help='Where on the part this reading was taken.',
)
equipment_model = fields.Char(
string='Equipment', default='Fischerscope XDAL 600',
)
product_ref = fields.Char(
string='Product Ref', help='e.g. "2805031 / NiP/Al-alloys 2805030"',
)
calibration_std_ref = fields.Char(
string='Calibration Std',
required=True,
default='NiP/Al STD SET SN 100174568',
help='Nadcap mandatory: which calibration standard the gauge '
'was checked against. Defaults to the shop\'s primary '
'standard but should be overridden if a different std '
'was used for this reading.',
)
microscope_image_id = fields.Many2one(
'ir.attachment', string='Microscope Image',
)
operator_id = fields.Many2one(
'res.users', string='Operator', default=lambda self: self.env.user,
)
reading_datetime = fields.Datetime(
string='Reading Date/Time', default=fields.Datetime.now,
)
measuring_time_seconds = fields.Integer(
string='Measuring Time (sec)', default=120,
)
@api.depends('reading_number', 'nip_mils', 'certificate_id')
def _compute_display_name(self):
for rec in self:
ctx = rec.certificate_id.display_name or ''
label = 'Reading #%d' % (rec.reading_number or 0)
if rec.nip_mils:
label = '%s (%.4f mils)' % (label, rec.nip_mils)
if ctx:
label = '%s%s' % (label, ctx)
rec.display_name = label