changes
This commit is contained in:
@@ -125,3 +125,42 @@ class FpPortalJob(models.Model):
|
||||
def _progress_percent(self):
|
||||
self.ensure_one()
|
||||
return self._state_progress_map().get(self.state, 0)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Customer-visible process steps
|
||||
#
|
||||
# Walks the linked production's recipe tree and returns only the
|
||||
# nodes the recipe author marked `customer_visible=True`. Used by
|
||||
# the portal job page so internal QC / setup / handling steps stay
|
||||
# hidden from the customer while the substantive process steps are
|
||||
# surfaced.
|
||||
# ------------------------------------------------------------------
|
||||
def get_customer_visible_steps(self):
|
||||
"""Return [{'name': str, 'icon': str, 'depth': int}] for portal display."""
|
||||
self.ensure_one()
|
||||
Production = self.env.get('mrp.production')
|
||||
if Production is None:
|
||||
return []
|
||||
mo = Production.sudo().search(
|
||||
[('x_fc_portal_job_id', '=', self.id)], limit=1,
|
||||
)
|
||||
if not mo or not mo.x_fc_recipe_id:
|
||||
return []
|
||||
|
||||
result = []
|
||||
def walk(node, depth):
|
||||
for child in node.child_ids.sorted('sequence'):
|
||||
if not child.customer_visible:
|
||||
# Hidden node — and its sub-tree is also hidden,
|
||||
# because if you're skipping the parent the kids
|
||||
# never make sense in isolation.
|
||||
continue
|
||||
result.append({
|
||||
'name': child.name,
|
||||
'icon': child.icon or 'fa-cog',
|
||||
'depth': depth,
|
||||
'node_type': child.node_type,
|
||||
})
|
||||
walk(child, depth + 1)
|
||||
walk(mo.x_fc_recipe_id, 0)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user