Commit 65c6fe60 authored by iv's avatar iv

ERP5Workflow: fix doActionFor method

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