Commit 65c6fe60 authored by iv's avatar iv

ERP5Workflow: fix doActionFor method

parent 5b174fa5
......@@ -189,29 +189,32 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
self.manage_renameObjects(ids=[pasted_workflow_id,],
new_ids=[new_workflow_id,])
def doActionFor(self, ob, action, wf_id=None, *args, **kw):
workflow_list = self.getWorkflowsFor(ob.getPortalType())
if wf_id is None:
def doActionFor(self, current_object, action_reference,
workflow_id=None, *args, **kw):
workflow_list = self.getWorkflowsFor(current_object.getPortalType())
action_id = action_reference
if workflow_id is None:
if workflow_list == []:
raise WorkflowException(_(u'No workflows found.'))
found = 0
for wf in workflow_list:
if wf.getPortalType() == 'Workflow':
action = 'transition_' + action
if wf.isActionSupported(ob, action, **kw):
for workflow in workflow_list:
if workflow.getPortalType() == 'Workflow':
action_id = 'transition_' + action_reference
if workflow.isActionSupported(current_object, action_id, **kw):
found = 1
break
if not found:
msg = _(u"No workflow provides the '${action_id}' action.",mapping={'action_id': action})
raise WorkflowException(msg)
message = "No workflow provides the %s action." % action_id
raise WorkflowException(message)
else:
wf = self.getWorkflowById(wf_id)
if wf is None:
workflow = self.getWorkflowById(workflow_id)
if workflow is None:
raise WorkflowException(_(u'Requested workflow definition not found.'))
if wf.getPortalType() == 'Workflow':
action = 'transition_' + action
if workflow.getPortalType() == 'Workflow':
action_id = 'transition_' + action_reference
result = self._invokeWithNotification(
workflow_list, ob, action, wf.doActionFor, (ob, action) + args, kw)
workflow_list, current_object, action_id, workflow.doActionFor,
(current_object, action_id) + args, kw)
return result
security.declareProtected(Permissions.AccessContentsInformation,
......
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