59 lines
1.4 KiB
Python
59 lines
1.4 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 fields, models
|
|
|
|
|
|
class FpKpiValue(models.Model):
|
|
"""KPI Daily Value.
|
|
|
|
One row per KPI per day. Auto-computed KPIs are populated by the
|
|
scheduled action; manual KPIs are entered by operators/supervisors.
|
|
"""
|
|
_name = 'fusion.plating.kpi.value'
|
|
_description = 'KPI Daily Value'
|
|
_order = 'date desc'
|
|
|
|
kpi_id = fields.Many2one(
|
|
'fusion.plating.kpi',
|
|
string='KPI',
|
|
required=True,
|
|
ondelete='cascade',
|
|
index=True,
|
|
)
|
|
date = fields.Date(
|
|
string='Date',
|
|
required=True,
|
|
default=fields.Date.today,
|
|
index=True,
|
|
)
|
|
value = fields.Float(
|
|
string='Value',
|
|
required=True,
|
|
)
|
|
facility_id = fields.Many2one(
|
|
'fusion.plating.facility',
|
|
string='Facility',
|
|
related='kpi_id.facility_id',
|
|
store=True,
|
|
)
|
|
kpi_type = fields.Selection(
|
|
related='kpi_id.kpi_type',
|
|
string='KPI Type',
|
|
store=True,
|
|
index=True,
|
|
)
|
|
company_id = fields.Many2one(
|
|
'res.company',
|
|
string='Company',
|
|
related='kpi_id.company_id',
|
|
store=True,
|
|
)
|
|
|
|
_sql_constraints = [
|
|
('kpi_date_uniq', 'unique(kpi_id, date)',
|
|
'Only one value per KPI per day is allowed.'),
|
|
]
|