changes
This commit is contained in:
@@ -19,7 +19,7 @@ class FpTank(models.Model):
|
||||
_name = 'fusion.plating.tank'
|
||||
_description = 'Fusion Plating — Tank'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_order = 'facility_id, work_center_id, sequence, code'
|
||||
_order = 'facility_id, section_id, sequence, code'
|
||||
|
||||
name = fields.Char(
|
||||
string='Tank Name',
|
||||
@@ -51,9 +51,16 @@ class FpTank(models.Model):
|
||||
ondelete='restrict',
|
||||
tracking=True,
|
||||
)
|
||||
section_id = fields.Many2one(
|
||||
'fusion.plating.tank.section',
|
||||
string='Section',
|
||||
ondelete='set null',
|
||||
tracking=True,
|
||||
help='Free-form grouping (e.g. Steel Line, Aluminum Line, Specialty Line).',
|
||||
)
|
||||
work_center_id = fields.Many2one(
|
||||
'fusion.plating.work.center',
|
||||
string='Work Center',
|
||||
string='Production Line',
|
||||
domain="[('facility_id','=',facility_id)]",
|
||||
ondelete='restrict',
|
||||
tracking=True,
|
||||
@@ -126,6 +133,22 @@ class FpTank(models.Model):
|
||||
tracking=True,
|
||||
)
|
||||
|
||||
# ----- Default temperature (used as pre-fill on bath log lines) -------
|
||||
default_temperature = fields.Float(
|
||||
string='Default Temperature',
|
||||
digits=(6, 2),
|
||||
tracking=True,
|
||||
help='Operating temperature setpoint. Pre-fills the temperature '
|
||||
'reading on new chemistry logs so the operator can confirm with '
|
||||
'one tap. Use the up/down arrows on the input to nudge by 1 unit.',
|
||||
)
|
||||
default_temperature_uom = fields.Selection(
|
||||
[('c', '°C'), ('f', '°F')],
|
||||
string='Temperature Unit',
|
||||
default='c',
|
||||
tracking=True,
|
||||
)
|
||||
|
||||
# ----- Relations ------------------------------------------------------
|
||||
bath_ids = fields.One2many(
|
||||
'fusion.plating.bath',
|
||||
@@ -138,16 +161,45 @@ class FpTank(models.Model):
|
||||
compute='_compute_current_bath',
|
||||
store=True,
|
||||
)
|
||||
current_bath_process_id = fields.Many2one(
|
||||
'fusion.plating.process.type',
|
||||
string='Current Bath Process',
|
||||
related='current_bath_id.process_type_id',
|
||||
store=True,
|
||||
help='Process derived from the active bath. The editable "Current '
|
||||
'Process" overrides this when the operator needs to flag a '
|
||||
'different process (e.g. between bath swaps).',
|
||||
)
|
||||
current_process_id = fields.Many2one(
|
||||
'fusion.plating.process.type',
|
||||
string='Current Process',
|
||||
related='current_bath_id.process_type_id',
|
||||
store=True,
|
||||
ondelete='restrict',
|
||||
tracking=True,
|
||||
help='User-settable process flag. Defaults to the active bath\'s '
|
||||
'process; can be overridden when operating off-recipe.',
|
||||
)
|
||||
bath_count = fields.Integer(
|
||||
compute='_compute_bath_count',
|
||||
)
|
||||
|
||||
# ----- Compositions ---------------------------------------------------
|
||||
composition_ids = fields.One2many(
|
||||
'fusion.plating.tank.composition',
|
||||
'tank_id',
|
||||
string='Compositions',
|
||||
)
|
||||
active_composition_id = fields.Many2one(
|
||||
'fusion.plating.tank.composition',
|
||||
string='Active Composition',
|
||||
domain="[('tank_id', '=', id)]",
|
||||
tracking=True,
|
||||
help='The composition currently in service. Switching is logged in '
|
||||
'the chatter for full audit history.',
|
||||
)
|
||||
composition_count = fields.Integer(
|
||||
compute='_compute_composition_count',
|
||||
)
|
||||
|
||||
_sql_constraints = [
|
||||
(
|
||||
'fp_tank_code_facility_uniq',
|
||||
@@ -168,6 +220,20 @@ class FpTank(models.Model):
|
||||
for rec in self:
|
||||
rec.bath_count = len(rec.bath_ids)
|
||||
|
||||
@api.depends('composition_ids')
|
||||
def _compute_composition_count(self):
|
||||
for rec in self:
|
||||
rec.composition_count = len(rec.composition_ids)
|
||||
|
||||
@api.onchange('current_bath_process_id')
|
||||
def _onchange_seed_current_process(self):
|
||||
"""Pre-fill the editable Current Process from the active bath when
|
||||
the operator hasn't already set one — keeps the field useful out of
|
||||
the box while still allowing manual override."""
|
||||
for rec in self:
|
||||
if not rec.current_process_id and rec.current_bath_process_id:
|
||||
rec.current_process_id = rec.current_bath_process_id
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
|
||||
Reference in New Issue
Block a user