Different facilities use different measurement systems. North-American
aerospace shops live in °F + mils + gallons + lb; ROW + most metric
shops use °C + microns + litres + kg. Add company-level defaults so
each shop picks its units once; new records inherit them automatically.
**Settings on res.company** (7 Selection fields):
• x_fc_default_temp_uom — °F / °C
• x_fc_default_thickness_uom — mils / microns / inches / mm
• x_fc_default_volume_uom — US gal / litres / Imp gal
• x_fc_default_mass_uom — lb / kg / oz / g
• x_fc_default_pressure_uom — psi / bar / kPa
• x_fc_default_current_density_uom — A/ft² (ASF) / A/dm² (ASD)
• x_fc_default_area_uom — sq in / sq ft / cm² / m²
All default to North-American aerospace conventions (F, mils, gal, lb,
psi, asf, sq_in) — admins flip them once during onboarding via
Settings → Fusion Plating → Units of Measure.
**Per-record use** (this round)
• mrp.workorder.x_fc_bake_temp_uom (°F / °C) — defaults from company,
operator can override per WO if a specific bake needs a different
unit (rare but allowed).
• Bake-finish gate error message now reports the actual unit:
"Bake Temp (°F)" or "Bake Temp (°C)" instead of hard-coded F.
• Form: Bake Temp + Temp Unit picker side-by-side in the bake group.
**Settings UI** — new "Units of Measure" block on Settings → Fusion
Plating page with help text per unit explaining where each is used.
**Verified end-to-end** (scripts/fp_uom_smoke.py):
• All 7 defaults populate with NA-aerospace defaults
• Switching company default to °C makes a NEW WO inherit °C
• Existing WOs keep their stored °F (no surprise mutation)
**Roadmap (deferred to next round)** — wire the same default-from-company
inheritance to:
• fp.bake.oven.target_temp (currently no UoM)
• fp.bake.window.bake_temp (currently no UoM)
• fp.coating.config.bake_temperature (currently no UoM)
• fp.tank.volume already has volume_uom; default from company
• fp.bath.log chemistry readings already use parameter.uom; align
with company default for new params
The settings + framework are now in place — adding more per-record uom
fields is mechanical from here.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
env = env # noqa
|
|
co = env.company
|
|
print('Company unit defaults on', co.name)
|
|
for f in ('x_fc_default_temp_uom', 'x_fc_default_thickness_uom',
|
|
'x_fc_default_volume_uom', 'x_fc_default_mass_uom',
|
|
'x_fc_default_pressure_uom', 'x_fc_default_current_density_uom',
|
|
'x_fc_default_area_uom'):
|
|
print(f' {f:<36} {getattr(co, f, "(missing)")}')
|
|
|
|
# Switch company default to Celsius and verify a new WO inherits it
|
|
print('\\nSwitching company default to °C...')
|
|
co.sudo().x_fc_default_temp_uom = 'C'
|
|
|
|
mo = env['mrp.production'].sudo().search([], order='id desc', limit=1)
|
|
if mo:
|
|
bake_wo = mo.workorder_ids.filtered(
|
|
lambda w: hasattr(w, '_fp_classify_kind') and w._fp_classify_kind() == 'bake'
|
|
)[:1]
|
|
if bake_wo:
|
|
# Existing WOs keep their stored value
|
|
print(f'existing bake WO {bake_wo.id}: x_fc_bake_temp_uom = {bake_wo.x_fc_bake_temp_uom}')
|
|
|
|
# New WO should default from current company setting
|
|
new_wo_vals = {
|
|
'production_id': mo.id, 'name': 'Test Bake WO',
|
|
'workcenter_id': mo.workorder_ids[0].workcenter_id.id,
|
|
}
|
|
new_wo = env['mrp.workorder'].sudo().create(new_wo_vals)
|
|
print(f'NEW WO {new_wo.id}: x_fc_bake_temp_uom = {new_wo.x_fc_bake_temp_uom} (should be C)')
|
|
new_wo.sudo().unlink()
|
|
|
|
# Restore F default
|
|
co.sudo().x_fc_default_temp_uom = 'F'
|
|
print('Restored to °F.')
|
|
env.cr.commit()
|