Follow-up to the company-level UoM defaults commit. Wires four more
unit-bearing fields to inherit from res.company defaults at create-time.
**1. fp.bake.oven**
• New `target_temp_uom` (°F / °C) — defaults from
company.x_fc_default_temp_uom.
• View: target_temp_min / max now render with a unit picker on the
same row instead of unitless floats. Rule of thumb: "350–380 °F".
**2. fp.bake.window**
• New `bake_temp_uom` — defaults from company.x_fc_default_temp_uom.
• View: replaced hardcoded `°F` span with a live unit picker so the
label matches whatever unit was actually recorded.
**3. fp.coating.config**
• New `bake_temperature_uom` — defaults from company.
• Removed hardcoded "Bake Temperature (°F)" label; the field is
now unit-agnostic and the unit travels with the value.
**4. fp.tank.volume_uom**
• Default now derives from company.x_fc_default_volume_uom via a
small mapping (gal → gal_us, L → l, imp_gal → gal_imp). The
selection itself stays the same — tanks already supported all
common volume units; we just pre-pick the right one per company.
**Verified end-to-end** (scripts/fp_uom_smoke2.py):
• Switching company default to °C + Litres
• New oven gets C ✓
• New bake window gets C ✓
• New coating config gets C ✓
• New tank gets `l` ✓ (mapped from company `L`)
• Restored defaults afterwards
Existing records keep their stored uom — no surprise mutation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
env = env # noqa
|
|
co = env.company
|
|
print(f'Company default temp: {co.x_fc_default_temp_uom}')
|
|
print(f'Company default volume: {co.x_fc_default_volume_uom}')
|
|
|
|
# Switch to metric
|
|
print('\n--- Switching company defaults to °C + Litres ---')
|
|
co.sudo().write({'x_fc_default_temp_uom': 'C', 'x_fc_default_volume_uom': 'L'})
|
|
|
|
# Test new oven inherits °C
|
|
fac = env['fusion.plating.facility'].search([], limit=1)
|
|
ov = env['fusion.plating.bake.oven'].sudo().create({
|
|
'name': 'Test Oven Metric', 'code': 'OVEN-TEST',
|
|
'facility_id': fac.id,
|
|
})
|
|
print(f'New oven target_temp_uom: {ov.target_temp_uom} (expect C)')
|
|
ov.unlink()
|
|
|
|
# Test new bake_window inherits °C
|
|
bw_vals = {
|
|
'bath_id': env['fusion.plating.bath'].search([], limit=1).id or False,
|
|
'lot_ref': 'TEST',
|
|
}
|
|
if bw_vals['bath_id']:
|
|
bw = env['fusion.plating.bake.window'].sudo().create(bw_vals)
|
|
print(f'New bake_window bake_temp_uom: {bw.bake_temp_uom} (expect C)')
|
|
bw.unlink()
|
|
|
|
# Test new coating config inherits °C
|
|
pt = env['fusion.plating.process.type'].search([], limit=1)
|
|
if pt:
|
|
cc = env['fp.coating.config'].sudo().create({
|
|
'name': 'Test Coating',
|
|
'process_type_id': pt.id,
|
|
})
|
|
print(f'New coating bake_temperature_uom: {cc.bake_temperature_uom} (expect C)')
|
|
cc.unlink()
|
|
|
|
# Test new tank inherits Litres mapping
|
|
f = env['fusion.plating.facility'].search([], limit=1)
|
|
wc = env['fusion.plating.work.center'].search([], limit=1)
|
|
if f and wc:
|
|
t = env['fusion.plating.tank'].sudo().create({
|
|
'name': 'Test Tank Metric', 'code': 'TANK-TEST',
|
|
'facility_id': f.id, 'work_center_id': wc.id,
|
|
})
|
|
print(f'New tank volume_uom: {t.volume_uom} (expect l)')
|
|
t.unlink()
|
|
|
|
# Restore
|
|
co.sudo().write({'x_fc_default_temp_uom': 'F', 'x_fc_default_volume_uom': 'gal'})
|
|
print('\nRestored to °F + gal.')
|
|
env.cr.commit()
|