feat(plating): wire deferred UoM defaults — bake oven, bake window, coating, tank
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>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
'name': 'Fusion Plating',
|
||||
'version': '19.0.5.2.0',
|
||||
'version': '19.0.5.3.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Core plating / metal finishing ERP: facilities, processes, tanks, baths, jobs, operators.',
|
||||
'description': """
|
||||
|
||||
@@ -72,7 +72,13 @@ class FpTank(models.Model):
|
||||
('m3', 'Cubic metres'),
|
||||
],
|
||||
string='Volume Unit',
|
||||
default='l',
|
||||
default=lambda self: {
|
||||
'gal': 'gal_us',
|
||||
'L': 'l',
|
||||
'imp_gal': 'gal_imp',
|
||||
}.get(self.env.company.x_fc_default_volume_uom or 'gal', 'gal_us'),
|
||||
help='Inherited from company default (Settings → Fusion Plating → '
|
||||
'Units of Measure). Overrideable per tank.',
|
||||
)
|
||||
material = fields.Selection(
|
||||
[
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
'name': 'Fusion Plating — Configurator',
|
||||
'version': '19.0.5.1.0',
|
||||
'version': '19.0.5.2.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Quotation configurator with part catalog, coating configs, and formula-based pricing engine.',
|
||||
'description': """
|
||||
|
||||
@@ -64,8 +64,14 @@ class FpCoatingConfig(models.Model):
|
||||
help='Maximum time between plate exit and bake start. Typically 4h per AMS 2759/9.',
|
||||
)
|
||||
bake_temperature = fields.Float(
|
||||
string='Bake Temperature (°F)', default=375.0,
|
||||
help='Relief bake temperature. Typical: 375°F for steel ≥ HRC 40.',
|
||||
string='Bake Temperature', default=375.0,
|
||||
help='Relief bake temperature. Default 375 (°F per AMS 2759/9 for '
|
||||
'steel ≥ HRC 40). Unit follows bake_temperature_uom.',
|
||||
)
|
||||
bake_temperature_uom = fields.Selection(
|
||||
[('F', '°F'), ('C', '°C')],
|
||||
string='Temp Unit',
|
||||
default=lambda self: self.env.company.x_fc_default_temp_uom or 'F',
|
||||
)
|
||||
bake_duration_hours = fields.Float(
|
||||
string='Bake Duration (hours)', default=23.0,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
'name': 'Fusion Plating — Shop Floor',
|
||||
'version': '19.0.14.2.0',
|
||||
'version': '19.0.14.3.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Shop-floor tablet stations, QR scanning, bake window enforcer, '
|
||||
'first-piece inspection gates.',
|
||||
|
||||
@@ -50,6 +50,13 @@ class FpBakeOven(models.Model):
|
||||
string='Target Temp Max',
|
||||
help='Upper bound of target oven temperature.',
|
||||
)
|
||||
target_temp_uom = fields.Selection(
|
||||
[('F', '°F'), ('C', '°C')],
|
||||
string='Temp Unit',
|
||||
default=lambda self: self.env.company.x_fc_default_temp_uom or 'F',
|
||||
help='Unit for the target temp range. Defaults to the company '
|
||||
'preference (Settings → Fusion Plating → Units of Measure).',
|
||||
)
|
||||
chart_recorder_ref = fields.Char(
|
||||
string='Chart Recorder Ref',
|
||||
help='Serial / asset reference of the chart recorder providing trace evidence.',
|
||||
|
||||
@@ -110,6 +110,13 @@ class FpBakeWindow(models.Model):
|
||||
)
|
||||
bake_temp = fields.Float(
|
||||
string='Bake Temp',
|
||||
help='Setpoint temperature recorded for the relief bake. '
|
||||
'Unit follows bake_temp_uom (defaults from company).',
|
||||
)
|
||||
bake_temp_uom = fields.Selection(
|
||||
[('F', '°F'), ('C', '°C')],
|
||||
string='Temp Unit',
|
||||
default=lambda self: self.env.company.x_fc_default_temp_uom or 'F',
|
||||
)
|
||||
bake_duration_hours = fields.Float(
|
||||
string='Bake Duration (hours)',
|
||||
|
||||
@@ -42,8 +42,14 @@
|
||||
<field name="work_center_id"/>
|
||||
</group>
|
||||
<group string="Targets">
|
||||
<field name="target_temp_min"/>
|
||||
<field name="target_temp_max"/>
|
||||
<label for="target_temp_min"/>
|
||||
<div class="o_row">
|
||||
<field name="target_temp_min" nolabel="1" class="oe_inline"/>
|
||||
<span class="ms-1 me-2">to</span>
|
||||
<field name="target_temp_max" nolabel="1" class="oe_inline"/>
|
||||
<field name="target_temp_uom" nolabel="1"
|
||||
class="oe_inline ms-1"/>
|
||||
</div>
|
||||
<field name="chart_recorder_ref"/>
|
||||
<field name="active"/>
|
||||
</group>
|
||||
|
||||
@@ -93,7 +93,8 @@
|
||||
<label for="bake_temp"/>
|
||||
<div class="o_row">
|
||||
<field name="bake_temp" nolabel="1" class="oe_inline"/>
|
||||
<span class="ms-1">°F</span>
|
||||
<field name="bake_temp_uom" nolabel="1"
|
||||
class="oe_inline ms-1"/>
|
||||
</div>
|
||||
<label for="bake_duration_hours"/>
|
||||
<div class="o_row">
|
||||
|
||||
53
fusion_plating/scripts/fp_uom_smoke2.py
Normal file
53
fusion_plating/scripts/fp_uom_smoke2.py
Normal file
@@ -0,0 +1,53 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user