feat(jobs): Sub 14 — configurable workflow state bar (Path B)

Replaces the generic Draft/Confirmed/In Progress/Done statusbar with
a shop-configurable list of plating-specific milestones. Bar advances
automatically as recipe steps complete; no manual button clicks.

What ships
==========

* New model: fp.job.workflow.state
  Catalog of milestones (name, code, sequence, color, triggers).
  Triggers can be:
    - trigger_default_kinds: "receiving,inspect" matches by step.default_kind
    - trigger_first_step_started: any wet/bake/mask/rack step started
    - trigger_all_steps_done: every non-cancelled step in done/skipped
    - block_when_quality_hold: held back while NCR/hold open
  Plus per-recipe-node override (see below).

* Default 7-state seed (data/fp_workflow_state_data.xml):
    Draft → Confirmed → Received → In Progress → Inspected → Shipped → Done
  noupdate=1 so per-shop edits survive module upgrade.

* Recipe-side trigger field on fusion.plating.process.node:
    triggers_workflow_state_id (Many2one, optional)
  Wins over default_kind matching. Lets the recipe author pin a
  specific step as a milestone trigger even when default_kind isn't
  set or doesn't match. Exposed in the Recipe Tree Editor properties
  panel (dropdown sourced from the catalog).

* fp.job.workflow_state_id (computed, stored)
  Iterates the catalog in sequence order; lands at the highest passed
  milestone. Recomputes on step state / kind / recipe_node / quality
  hold changes. Replaces fp.job.state on the form's statusbar.

* Settings UI: Configuration > Workflow States
  Standard list+form pages so admins can add / edit / deactivate
  states. Manager-group write permission, supervisor read.

What this does NOT do
=====================
  * Doesn't drop fp.job.state — that field still drives the internal
    state machine (button_confirm, action_cancel, etc.). Only the
    UI statusbar is reassigned.
  * No migration for existing jobs — they auto-recompute on next read
    because workflow_state_id is a stored compute with the right
    api.depends. Existing WH/JOB/00342 will display its current
    workflow state on next page load.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-03 23:39:38 -04:00
parent 4c6bad04c5
commit 4e0b74d7ae
12 changed files with 564 additions and 2 deletions

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2026 Nexa Systems Inc.
License OPL-1 (Odoo Proprietary License v1.0)
Sub 14 — Default 7-state workflow milestone catalog.
Shops can edit, deactivate, or add their own states via
Settings → Fusion Plating → Workflow States. These records use
noupdate="1" so per-shop edits aren't blown away on module upgrade.
-->
<odoo>
<data noupdate="1">
<record id="workflow_state_draft" model="fp.job.workflow.state">
<field name="name">Draft</field>
<field name="code">draft</field>
<field name="sequence">10</field>
<field name="color">grey</field>
<field name="is_initial" eval="True"/>
<field name="description">Job created from SO, not yet kicked off. Awaiting setup or start-of-day batch.</field>
</record>
<record id="workflow_state_confirmed" model="fp.job.workflow.state">
<field name="name">Confirmed</field>
<field name="code">confirmed</field>
<field name="sequence">20</field>
<field name="color">blue</field>
<field name="description">SO confirmed, recipe locked, parts on order. Financially committed.</field>
</record>
<record id="workflow_state_received" model="fp.job.workflow.state">
<field name="name">Received</field>
<field name="code">received</field>
<field name="sequence">30</field>
<field name="color">cyan</field>
<field name="trigger_default_kinds">receiving</field>
<field name="description">Parts physically on the floor — production CAN start. Triggered by completion of any step with default_kind='receiving'.</field>
</record>
<record id="workflow_state_in_progress" model="fp.job.workflow.state">
<field name="name">In Progress</field>
<field name="code">in_progress</field>
<field name="sequence">40</field>
<field name="color">yellow</field>
<field name="trigger_first_step_started" eval="True"/>
<field name="description">First wet/production step started. Line is running, real shop time accruing. Triggered by any step with kind in (wet, bake, mask, rack) reaching in_progress or beyond.</field>
</record>
<record id="workflow_state_inspected" model="fp.job.workflow.state">
<field name="name">Inspected</field>
<field name="code">inspected</field>
<field name="sequence">50</field>
<field name="color">green</field>
<field name="trigger_default_kinds">final_inspect</field>
<field name="block_when_quality_hold" eval="True"/>
<field name="description">Final inspection passed AND no open quality hold. Safe to generate CoC + invoice. Blocked while any quality hold is open.</field>
</record>
<record id="workflow_state_shipped" model="fp.job.workflow.state">
<field name="name">Shipped</field>
<field name="code">shipped</field>
<field name="sequence">60</field>
<field name="color">success</field>
<field name="trigger_default_kinds">ship</field>
<field name="description">Shipment confirmed (BOL or carrier pickup). Customer can be notified.</field>
</record>
<record id="workflow_state_done" model="fp.job.workflow.state">
<field name="name">Done</field>
<field name="code">done</field>
<field name="sequence">70</field>
<field name="color">success</field>
<field name="is_terminal" eval="True"/>
<field name="trigger_all_steps_done" eval="True"/>
<field name="description">Every non-cancelled step is in done/skipped state. Audit trail closed.</field>
</record>
</data>
</odoo>