# -*- coding: utf-8 -*- # Copyright 2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) """Lightweight extension of fusion.plating.tank to surface its mapped sensors + latest reading state inline on the tank form. """ from odoo import api, fields, models class FusionPlatingTank(models.Model): _inherit = 'fusion.plating.tank' x_fc_sensor_ids = fields.One2many( 'fp.tank.sensor', 'tank_id', string='Sensors', ) x_fc_sensor_count = fields.Integer( string='Sensor Count', compute='_compute_sensor_stats', ) x_fc_has_out_of_spec = fields.Boolean( string='Any Sensor Out of Spec', compute='_compute_sensor_stats', help='True if ANY mapped sensor\'s latest reading is out of spec.', ) @api.depends('x_fc_sensor_ids.last_reading_in_spec', 'x_fc_sensor_ids.last_reading_at') def _compute_sensor_stats(self): for tank in self: live = tank.x_fc_sensor_ids.filtered(lambda s: s.last_reading_at) tank.x_fc_sensor_count = len(tank.x_fc_sensor_ids) tank.x_fc_has_out_of_spec = any( not s.last_reading_in_spec for s in live )