Revert "feat(jobs): step sequences are 1, 2, 3, ... not 10, 20, 30, ..."

This reverts commit 32d48ea44d.
This commit is contained in:
gsinghpal
2026-05-03 23:30:37 -04:00
parent 32d48ea44d
commit 4c6bad04c5
7 changed files with 33 additions and 39 deletions

View File

@@ -271,7 +271,7 @@ class SimpleRecipeController(http.Controller):
'template_id': tpl.id,
'name': (payload or {}).get('name') or 'New Prompt',
'input_type': (payload or {}).get('input_type') or 'text',
'sequence': existing_max + 1,
'sequence': existing_max + 10,
'required': bool((payload or {}).get('required')),
})
return {'ok': True, 'input_id': rec.id,
@@ -356,26 +356,25 @@ class SimpleRecipeController(http.Controller):
return {'id': new_node.id, 'sequence': new_node.sequence}
def _sequence_for_position(self, recipe, position):
"""Return the sequence value for a NEW step inserted at
`position` among the recipe's existing children.
Always renumbers existing siblings so the result is contiguous
1, 2, 3, ... matching what the operator sees on the work order.
(Pre-Sub 13c we used 10-spacing to allow midpoint inserts —
operators kept asking why their first step said "Step 10".)
"""
siblings = recipe.child_ids.sorted('sequence')
if not siblings:
return 1
pos = max(0, min(position, len(siblings)))
# Make room: siblings before `pos` keep their 1-based index;
# siblings at or after `pos` shift up by one so the new step
# lands at sequence (pos + 1).
return 10
if position >= len(siblings):
return siblings[-1].sequence + 10
if position <= 0:
return max(1, siblings[0].sequence - 10)
before = siblings[position - 1].sequence
after = siblings[position].sequence
if after - before > 1:
return (before + after) // 2
# Sequences are tightly packed (gap == 1 → midpoint == after,
# which collides). Renumber siblings to 10/20/30… first, then
# the new step lands cleanly between renumbered neighbours.
for idx, sib in enumerate(siblings):
target = idx + 1 if idx < pos else idx + 2
if sib.sequence != target:
sib.sequence = target
return pos + 1
new_seq = (idx + 1) * 10
if sib.sequence != new_seq:
sib.sequence = new_seq
return position * 10 + 5
def _copy_inputs_from_template(self, tpl, new_node):
NodeInput = request.env['fusion.plating.process.node.input']
@@ -413,7 +412,7 @@ class SimpleRecipeController(http.Controller):
def step_reorder(self, node_ids):
Node = request.env['fusion.plating.process.node']
for i, nid in enumerate(node_ids, start=1):
Node.browse(nid).write({'sequence': i})
Node.browse(nid).write({'sequence': i * 10})
return {'ok': True}
# -------------------------------------------------------------- template
@@ -522,7 +521,7 @@ class SimpleRecipeController(http.Controller):
'input_type': (payload or {}).get('input_type') or 'text',
'kind': 'step_input',
'collect': True,
'sequence': existing_max + 1,
'sequence': existing_max + 10,
'required': bool((payload or {}).get('required')),
})
return {'ok': True, 'input_id': rec.id}