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

@@ -102,6 +102,7 @@ export class RecipeTreeEditor extends Component {
this.state = useState({
recipe: null,
tree: null,
workflowStates: [], // Sub 14 — populated by loadTree
loading: false,
saving: false,
selectedNodeId: null,
@@ -157,6 +158,9 @@ export class RecipeTreeEditor extends Component {
if (result && result.ok) {
this.state.recipe = result.recipe;
this.state.tree = result.tree;
// Sub 14 — workflow states for the per-step trigger
// dropdown in the properties panel.
this.state.workflowStates = result.workflow_states || [];
// Auto-expand every node on first load AND auto-expand
// any node we haven't seen before (e.g. freshly imported
// nodes after a "Import from recipe" run). Nodes the
@@ -271,6 +275,8 @@ export class RecipeTreeEditor extends Component {
// Sub 13 — sequential enforcement
enforce_sequential: !!node.enforce_sequential,
parallel_start: !!node.parallel_start,
// Sub 14 — workflow milestone trigger
triggers_workflow_state_id: node.triggers_workflow_state_id || false,
};
const result = await rpc("/fp/recipe/node/write", {
node_id: node.id,

View File

@@ -374,6 +374,31 @@
</div>
</div>
<!-- Sub 14 — workflow milestone trigger (operation / step nodes) -->
<div class="o_fp_re_field"
t-if="(state.selectedNode.node_type === 'operation' or state.selectedNode.node_type === 'step') and state.workflowStates.length">
<label for="fp_re_workflow_state">Triggers Workflow State</label>
<select id="fp_re_workflow_state"
class="form-select"
t-on-change="(ev) => { state.selectedNode.triggers_workflow_state_id = ev.target.value ? parseInt(ev.target.value, 10) : false; }">
<option value=""
t-att-selected="!state.selectedNode.triggers_workflow_state_id">
— None (use default-kind matching) —
</option>
<t t-foreach="state.workflowStates" t-as="ws" t-key="ws.id">
<option t-att-value="ws.id"
t-att-selected="state.selectedNode.triggers_workflow_state_id === ws.id"
t-esc="ws.name"/>
</t>
</select>
<small class="text-muted d-block mt-1">
When this step finishes (or is skipped/cancelled), the
job's status bar advances to the chosen state. Leave
blank to fall back to the default-kind mapping
configured on the workflow state catalog.
</small>
</div>
<div class="o_fp_re_field">
<label>Step Usage</label>
<select class="form-select"