changes
This commit is contained in:
5
fusion-plating/fusion_plating_sensors/wizard/__init__.py
Normal file
5
fusion-plating/fusion_plating_sensors/wizard/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
|
||||
from . import fp_sensor_measure_wizard
|
||||
@@ -0,0 +1,57 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class FpSensorMeasureWizard(models.TransientModel):
|
||||
"""Quick measurement entry wizard.
|
||||
|
||||
Opened from the "+ Measure" button on the sensor form.
|
||||
Pre-fills sensor and unit, operator enters value + date + comment.
|
||||
"""
|
||||
_name = 'fp.sensor.measure.wizard'
|
||||
_description = 'Record Sensor Measurement'
|
||||
|
||||
sensor_id = fields.Many2one(
|
||||
'fp.sensor',
|
||||
string='Sensor',
|
||||
required=True,
|
||||
readonly=True,
|
||||
)
|
||||
measurement_type = fields.Selection(
|
||||
related='sensor_id.measurement_type',
|
||||
readonly=True,
|
||||
)
|
||||
unit = fields.Char(
|
||||
related='sensor_id.unit',
|
||||
readonly=True,
|
||||
)
|
||||
value = fields.Float(string='Value')
|
||||
value_text = fields.Char(string='Text Value')
|
||||
value_bool = fields.Boolean(string='Boolean Value')
|
||||
effective_at = fields.Datetime(
|
||||
string='Date',
|
||||
default=fields.Datetime.now,
|
||||
required=True,
|
||||
)
|
||||
comment = fields.Text(string='Comment')
|
||||
|
||||
def action_confirm(self):
|
||||
self.ensure_one()
|
||||
vals = {
|
||||
'sensor_id': self.sensor_id.id,
|
||||
'effective_at': self.effective_at,
|
||||
'comment': self.comment,
|
||||
'source': 'manual',
|
||||
}
|
||||
mtype = self.sensor_id.measurement_type
|
||||
if mtype == 'number':
|
||||
vals['value'] = self.value
|
||||
elif mtype == 'text':
|
||||
vals['value_text'] = self.value_text
|
||||
elif mtype == 'boolean':
|
||||
vals['value_bool'] = self.value_bool
|
||||
self.env['fp.sensor.measurement'].create(vals)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
Reference in New Issue
Block a user