fix(fusion_iot): respect company temperature-unit preference in sensor UI

The sensor readings list always showed raw °C regardless of the
Plating Settings Temperature Unit preference (res.company.x_fc_default_temp_uom).
On a Fahrenheit-preferred shop, a 40°C reading should render as 105°F.

Fix: add display-aware computed fields alongside the canonical ones.

**fp.tank.reading**
- `value` / `unit` renamed with "(raw)" labels — these are the stored
  canonical values (always °C for temperature, because every
  temperature chip reports in Celsius natively)
- `display_value` + `display_unit` computed from company pref — only
  flips C→F when parameter_type='temperature' AND company pref='F';
  pH/conductivity/etc pass through untouched
- `display_name` now uses display_value so it reads naturally
  ("Sensor — 105.58 °F @ ...") regardless of region

**fp.tank.sensor**
- Mirrored the same pattern on the cached last-reading fields
- `last_reading_display` + `last_reading_display_unit` for lists
- `last_reading_value` hidden behind group_no_one (debug-only)

**Views**
- fp.tank.reading list: show display_value/display_unit, raw value
  hidden by default (toggle from column picker if needed)
- fp.tank.sensor list + form + tank inline: same pattern
- Raw value kept visible as an optional column so data engineers
  can still audit canonical storage

Why store canonical: spec thresholds (alert_min/max) live on the
sensor in °C. If the same Odoo serves a multi-region company
(Canada in C, US affiliate in F), switching a single preference
flips every UI without touching data. Alert logic keeps comparing
canonical values, so out-of-spec holds fire correctly regardless
of display unit.

Verified: 40.88°C raw → 105.58°F display on the live pilot probe
with company pref='F'. All 5 recent readings tested, display
fields updated correctly on every poll.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-04-20 16:13:17 -04:00
parent dd575135ae
commit 089cda71fe
6 changed files with 83 additions and 16 deletions

View File

@@ -15,8 +15,9 @@
<field name="sensor_id"/>
<field name="tank_id" optional="show"/>
<field name="parameter_id" optional="hide"/>
<field name="value"/>
<field name="unit"/>
<field name="display_value"/>
<field name="display_unit"/>
<field name="value" optional="hide" string="Value (°C raw)"/>
<field name="in_spec" widget="boolean_toggle"/>
<field name="source" optional="hide"/>
<field name="hold_id" optional="show"/>
@@ -39,8 +40,10 @@
</group>
<group>
<field name="reading_at"/>
<field name="value"/>
<field name="unit" readonly="1"/>
<field name="display_value" readonly="1"/>
<field name="display_unit" readonly="1"/>
<field name="value" readonly="1"
string="Stored Value (°C, canonical)"/>
<field name="in_spec" readonly="1"/>
<field name="hold_id" readonly="1"/>
</group>

View File

@@ -19,7 +19,9 @@
<field name="parameter_id"/>
<field name="device_serial" optional="show"/>
<field name="iot_device_id" optional="hide"/>
<field name="last_reading_value"/>
<field name="last_reading_display"/>
<field name="last_reading_display_unit"/>
<field name="last_reading_value" optional="hide" string="Latest Raw (°C)"/>
<field name="last_reading_at"/>
<field name="last_reading_in_spec" widget="boolean_toggle"/>
<field name="reading_count"/>
@@ -76,7 +78,11 @@
help="Leave 0 to inherit from the bath parameter's target_max."/>
</group>
<group string="Most Recent Reading">
<field name="last_reading_value" readonly="1"/>
<field name="last_reading_display" readonly="1"/>
<field name="last_reading_display_unit" readonly="1"/>
<field name="last_reading_value" readonly="1"
string="Stored (°C canonical)"
groups="base.group_no_one"/>
<field name="last_reading_at" readonly="1"/>
<field name="last_reading_in_spec" readonly="1" widget="boolean_toggle"/>
</group>

View File

@@ -24,7 +24,8 @@
<field name="device_kind"/>
<field name="device_serial"/>
<field name="parameter_id"/>
<field name="last_reading_value"/>
<field name="last_reading_display"/>
<field name="last_reading_display_unit"/>
<field name="last_reading_at" readonly="1"/>
<field name="last_reading_in_spec" widget="boolean_toggle"/>
<field name="alert_on_out_of_spec" widget="boolean_toggle"/>