changes
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class FpDischargeSampleLine(models.Model):
|
||||
_name = 'fusion.plating.discharge.sample.line'
|
||||
_description = 'Fusion Plating - Discharge Sample Line'
|
||||
_order = 'sample_id, id'
|
||||
|
||||
sample_id = fields.Many2one('fusion.plating.discharge.sample', string='Sample', required=True, ondelete='cascade')
|
||||
limit_id = fields.Many2one('fusion.plating.discharge.limit', string='Limit', ondelete='restrict')
|
||||
parameter = fields.Char(string='Parameter', related='limit_id.parameter', store=True, readonly=False)
|
||||
value = fields.Float(string='Result', digits=(16, 4))
|
||||
uom = fields.Char(string='UoM')
|
||||
status = fields.Selection(
|
||||
[('ok', 'OK'), ('warning', 'Warning'), ('out_of_spec', 'Out of Spec'), ('pending', 'Pending')],
|
||||
string='Status', compute='_compute_status', store=True,
|
||||
)
|
||||
notes = fields.Char(string='Note')
|
||||
|
||||
@api.depends('value', 'limit_id', 'limit_id.limit_value', 'limit_id.limit_type', 'limit_id.min_value')
|
||||
def _compute_status(self):
|
||||
for rec in self:
|
||||
if not rec.limit_id:
|
||||
rec.status = 'pending'
|
||||
continue
|
||||
limit = rec.limit_id
|
||||
lt = limit.limit_type
|
||||
lv = limit.limit_value or 0.0
|
||||
if lt == 'max' or lt == 'ceiling':
|
||||
if lv <= 0:
|
||||
rec.status = 'pending'
|
||||
elif rec.value >= lv:
|
||||
rec.status = 'out_of_spec'
|
||||
elif rec.value >= 0.8 * lv:
|
||||
rec.status = 'warning'
|
||||
else:
|
||||
rec.status = 'ok'
|
||||
elif lt == 'min':
|
||||
if rec.value < lv:
|
||||
rec.status = 'out_of_spec'
|
||||
elif rec.value <= 1.2 * lv:
|
||||
rec.status = 'warning'
|
||||
else:
|
||||
rec.status = 'ok'
|
||||
elif lt == 'range':
|
||||
if rec.value < (limit.min_value or 0.0) or rec.value > lv:
|
||||
rec.status = 'out_of_spec'
|
||||
elif rec.value >= 0.8 * lv:
|
||||
rec.status = 'warning'
|
||||
else:
|
||||
rec.status = 'ok'
|
||||
else:
|
||||
rec.status = 'pending'
|
||||
Reference in New Issue
Block a user