Files
Odoo-Modules/fusion_plating/fusion_plating/models/fp_bath_parameter.py
gsinghpal 13e300d90e changes
2026-04-28 19:39:37 -04:00

118 lines
3.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
from ._fp_uom_selection import FP_UOM_SELECTION
class FpBathParameter(models.Model):
"""Definition of a bath chemistry parameter.
Parameters are process-agnostic at the schema level (e.g. "Temperature",
"pH", "Nickel concentration"). Each process type references a set of
parameters via fusion.plating.process.type.parameter_ids. Actual target
ranges per bath are stored on fusion.plating.bath (per-bath overrides)
or on the bath recipe.
"""
_name = 'fusion.plating.bath.parameter'
_description = 'Fusion Plating — Bath Parameter'
_order = 'sequence, name'
name = fields.Char(
string='Parameter',
required=True,
translate=True,
help='Display name (e.g. "Nickel Concentration", "pH").',
)
code = fields.Char(
string='Code',
required=True,
help='Short code used in logs and exports (e.g. "Ni", "PH", "TEMP").',
)
sequence = fields.Integer(
string='Sequence',
default=10,
)
parameter_type = fields.Selection(
[
('concentration', 'Concentration'),
('temperature', 'Temperature'),
('ph', 'pH'),
('conductivity', 'Conductivity'),
('turbidity', 'Turbidity'),
('ratio', 'Ratio'),
('count', 'Count / Age'),
('other', 'Other'),
],
string='Type',
required=True,
default='concentration',
)
uom = fields.Selection(
FP_UOM_SELECTION,
string='Unit',
help='Pick the unit this parameter is measured in. Drives the unit '
'shown on every reading, target, and replenishment suggestion '
'derived from this parameter.',
)
uom_display = fields.Char(
string='Unit (display)',
compute='_compute_uom_display',
help='Resolved display string for the chosen unit '
'(e.g. "g/L", "°C") — used by views that need plain text.',
)
target_min = fields.Float(
string='Default Target Min',
help='Smallest acceptable reading, expressed in the unit selected '
'above. Anything below this is flagged Out of Spec. '
'Per-bath overrides allowed.',
)
target_max = fields.Float(
string='Default Target Max',
help='Largest acceptable reading, expressed in the unit selected '
'above. Anything above this is flagged Out of Spec. '
'Per-bath overrides allowed.',
)
target_value = fields.Float(
string='Default Setpoint / Optimum',
help='The IDEAL operating value, expressed in the unit selected '
'above — what the heater/chiller controls toward, what '
'dashboards compare against. Sits between Target Min and '
'Target Max. Per-sensor override via '
'fp.tank.sensor.target_value_override.',
)
warning_tolerance = fields.Float(
string='Warning Tolerance %',
default=10.0,
help='Distance from target limit at which a reading is flagged as warning.',
)
decimals = fields.Integer(
string='Decimals',
default=2,
)
description = fields.Text(
string='Description',
translate=True,
)
active = fields.Boolean(
string='Active',
default=True,
)
@api.depends('uom')
def _compute_uom_display(self):
labels = dict(FP_UOM_SELECTION)
for rec in self:
rec.uom_display = labels.get(rec.uom, '') if rec.uom else ''
_sql_constraints = [
(
'fp_bath_parameter_code_uniq',
'unique(code)',
'Bath parameter code must be unique.',
),
]