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:
@@ -19,11 +19,27 @@ class FpRecipeController(http.Controller):
|
||||
# ------------------------------------------------------------------
|
||||
@http.route('/fp/recipe/tree', type='jsonrpc', auth='user')
|
||||
def get_tree(self, recipe_id):
|
||||
"""Return the full nested tree for a recipe."""
|
||||
"""Return the full nested tree for a recipe + the workflow
|
||||
states catalog for the per-step "Triggers Workflow State"
|
||||
dropdown in the properties panel (Sub 14).
|
||||
"""
|
||||
Node = request.env['fusion.plating.process.node']
|
||||
recipe = Node.browse(int(recipe_id))
|
||||
if not recipe.exists():
|
||||
return {'ok': False, 'error': f'Recipe {recipe_id} not found.'}
|
||||
# Workflow states for the dropdown — runtime-detect the model
|
||||
# so the tree editor still works on installs without
|
||||
# fusion_plating_jobs (where the model lives).
|
||||
workflow_states = []
|
||||
WS = request.env.get('fp.job.workflow.state')
|
||||
if WS is not None:
|
||||
for ws in WS.search([('active', '=', True)], order='sequence, id'):
|
||||
workflow_states.append({
|
||||
'id': ws.id,
|
||||
'name': ws.name or '',
|
||||
'code': ws.code or '',
|
||||
'sequence': ws.sequence,
|
||||
})
|
||||
return {
|
||||
'ok': True,
|
||||
'recipe': {
|
||||
@@ -34,6 +50,7 @@ class FpRecipeController(http.Controller):
|
||||
'process_type': recipe.process_type_id.name if recipe.process_type_id else '',
|
||||
},
|
||||
'tree': recipe.get_tree_data(),
|
||||
'workflow_states': workflow_states,
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
@@ -88,6 +105,8 @@ class FpRecipeController(http.Controller):
|
||||
'requires_signoff', 'opt_in_out', 'sequence', 'version',
|
||||
# Sub 13 — sequential enforcement
|
||||
'enforce_sequential', 'parallel_start',
|
||||
# Sub 14 — workflow milestone trigger
|
||||
'triggers_workflow_state_id',
|
||||
}
|
||||
safe_vals = {k: v for k, v in vals.items() if k in allowed}
|
||||
if not safe_vals:
|
||||
|
||||
Reference in New Issue
Block a user