feat(plating): per-WO-kind equipment fields + smart auto-fill defaults

User caught two related issues from screenshots of the WO form:

  1. The "Plating Details" tab was meaningless for non-wet WOs —
     bath/tank/dwell/thickness all show as empty for masking, oven
     bake, racking, and inspection steps. A shop with multiple ovens
     had no way to record which oven a bake WO ran in.

  2. When there's only ONE option (single oven, single bath), forcing
     the manager to pick it on every WO is busywork — pin it
     automatically.

**1. WO classification + per-kind equipment**

New `x_fc_wo_kind` (compute, non-stored) Selection field that buckets
each WO into one of: wet / bake / mask / rack / inspect / other.
Classification by priority:
  • bath linked → wet
  • oven linked → bake
  • workcenter's process families wet → wet
  • WO name keyword match (bake/oven/cure → bake;
    mask/de-mask → mask; rack/de-rack → rack;
    inspect/qa/qc/fai → inspect; default → other)

New equipment fields per kind:
  • `x_fc_oven_id` (m2o fp.bake.oven) for bake WOs
  • `x_fc_bake_temp`, `x_fc_bake_duration_hours` — bake parameters
  • Existing bath/tank/rack/thickness reused for wet
  • Existing rack reused for rack WOs

**2. Required-fields gate extended**

button_start now also requires `x_fc_oven_id` for bake WOs (alongside
the existing operator + bath/tank rules). Without an oven the
chart-recorder trail can't be tied back to the WO for compliance.

**3. View reorganized**

Process Details tab now shows only the equipment groups that apply
to this WO's kind (using `invisible="x_fc_wo_kind != 'bake'"` etc.).
Mask + Inspection + Other show informational alerts instead of
empty form fields. WO header shows a colour-coded kind badge.

**4. Smart auto-fill defaults**

New `_fp_autofill_default_equipment()` method on mrp.workorder. When
the facility has exactly ONE active option, it pre-pins:
  • Bath → if facility has 1 active bath
  • Tank → if the chosen bath has 1 active tank
  • Oven → if facility has 1 active oven

Hooked from:
  • `@api.onchange('workcenter_id', 'x_fc_facility_id', 'x_fc_bath_id')`
    → fills as user edits in the form
  • Recipe → WO generation `_generate_workorders_from_recipe()`
    → fills at creation time so single-line shops never see an
    empty bath/oven field

None of this overwrites an already-set value. Multi-line shops still
get a blank field to choose from.

**Simulator updates** (scripts/fp_e2e_workforce.py)
  • Creates an oven if none exists
  • Pins per-kind equipment in Hannah's planning step
  • New PASS check: bake-WO auto-pinned to default oven
  • New negative test 2b: bake WO with oven stripped → blocked

**Final E2E**: 54 PASS / 2 WARN / 0 FAIL out of 56 checks.
12 negative tests passing — all gates fire when triggered:
  Tests 1-2 + 2b: WO start (operator + bath/tank + oven)
  Tests 3-7: MO facility, cert spec, delivery POD, invoice
             payment terms, thickness cal std
  Tests 8-11: NCR close, CAPA close, discharge close, invoice ref

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-04-19 10:47:01 -04:00
parent 6e964c230f
commit 2804168d9e
5 changed files with 252 additions and 21 deletions

View File

@@ -96,7 +96,12 @@
required="1"
options="{'no_create': True}"/>
<field name="x_fc_work_role_id" readonly="1"/>
<field name="x_fc_wo_kind" widget="badge" readonly="1"
decoration-info="x_fc_wo_kind == 'wet'"
decoration-warning="x_fc_wo_kind == 'bake'"
decoration-muted="x_fc_wo_kind in ('mask', 'rack', 'inspect', 'other')"/>
<field name="x_fc_requires_bath" invisible="1"/>
<field name="x_fc_requires_oven" invisible="1"/>
</xpath>
<!-- ============================================================
@@ -162,12 +167,21 @@
</group>
</xpath>
<!-- 5b. Plating Details tab (insert AFTER Time & Cost) -->
<!-- 5b. Process Details tab — content adapts to WO kind so
operators see only the equipment fields that matter for
their step (bath/tank for wet, oven for bake, etc.). -->
<xpath expr="//notebook/page[@name='time_tracking']" position="after">
<page string="Plating Details" name="plating_details">
<page string="Process Details" name="plating_details">
<!-- Always-visible: facility (set everywhere) -->
<group>
<group string="Bath &amp; Tank">
<group string="Where">
<field name="x_fc_facility_id"/>
</group>
</group>
<!-- Wet / bath WOs (plating, etch, rinse, strip, ...) -->
<group invisible="x_fc_wo_kind != 'wet'">
<group string="Bath &amp; Tank">
<field name="x_fc_bath_id"
required="x_fc_requires_bath"/>
<field name="x_fc_tank_id"
@@ -181,6 +195,54 @@
<field name="x_fc_dwell_time_minutes"/>
</group>
</group>
<!-- Bake / cure WOs -->
<group invisible="x_fc_wo_kind != 'bake'">
<group string="Oven">
<field name="x_fc_oven_id"
required="x_fc_requires_oven"/>
</group>
<group string="Bake Parameters">
<field name="x_fc_bake_temp"/>
<field name="x_fc_bake_duration_hours"/>
</group>
</group>
<!-- Rack / de-rack WOs -->
<group invisible="x_fc_wo_kind != 'rack'">
<group string="Rack">
<field name="x_fc_rack_id"/>
<field name="x_fc_rack_ref"/>
</group>
</group>
<!-- Mask / De-mask WOs — workcenter is the bench;
no extra equipment fields, just a hint -->
<group invisible="x_fc_wo_kind != 'mask'">
<div class="alert alert-info" role="alert">
Masking / de-masking — work centre identifies
the bench. Use chatter for any per-job notes
on tape pattern, masking material, etc.
</div>
</group>
<!-- Inspection / QC WOs -->
<group invisible="x_fc_wo_kind != 'inspect'">
<div class="alert alert-info" role="alert">
Inspection — record Fischerscope readings via
the Tablet Station (calibration std + n
measurements per part). Readings auto-link
to the CoC at MO done.
</div>
</group>
<!-- Generic WOs that don't fit any bucket -->
<group invisible="x_fc_wo_kind != 'other'">
<div class="alert alert-light text-muted" role="alert">
Generic operation — equipment is identified
by the work centre. Use chatter for job notes.
</div>
</group>
</page>
</xpath>