Commit 9a7975a8 authored by Julien Muchembled's avatar Julien Muchembled

Add a method to workflow tool to know if a given transition exists from the current state.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27693 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 092207f6
......@@ -771,3 +771,14 @@ WorkflowTool.setStatusOf = WorkflowTool_setStatusOf
WorkflowTool.getFutureStateSetFor = lambda self, wf_id, *args, **kw: \
self[wf_id].getFutureStateSet(*args, **kw)
def WorkflowTool_isTransitionPossible(self, ob, transition_id, wf_id=None):
"""Test if the given transition exist from the current state.
"""
for workflow in (wf_id and (self[wf_id],) or self.getWorkflowsFor(ob)):
state = workflow._getWorkflowStateOf(ob)
if state and transition_id in state.transitions:
return 1
return 0
WorkflowTool.isTransitionPossible = WorkflowTool_isTransitionPossible
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment