Commit 2e15c269 authored by wenjie.zheng's avatar wenjie.zheng Committed by Sebastien Robin

ERP5WorkflowTool.py: correct logic error; add universal methods.

parent 59deb20f
...@@ -108,7 +108,7 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -108,7 +108,7 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool):
_manage_selectWorkflows = OriginalWorkflowTool._manage_selectWorkflows _manage_selectWorkflows = OriginalWorkflowTool._manage_selectWorkflows
manage_selectWorkflows = OriginalWorkflowTool.manage_selectWorkflows manage_selectWorkflows = OriginalWorkflowTool.manage_selectWorkflows
manage_changeWorkflows = OriginalWorkflowTool.manage_changeWorkflows manage_changeWorkflows = OriginalWorkflowTool.manage_changeWorkflows
# Declarative properties # Declarative properties
property_sheets = ( property_sheets = (
PropertySheet.Base, PropertySheet.Base,
PropertySheet.XMLObject, PropertySheet.XMLObject,
...@@ -129,7 +129,7 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -129,7 +129,7 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool):
raise WorkflowException('No workflows found.') raise WorkflowException('No workflows found.')
found = False found = False
for workflow in workflow_list: for workflow in workflow_list:
if not isinstance(workflow, InteractionWorkflowDefinition) or \ if not isinstance(workflow, InteractionWorkflowDefinition) and \
not isinstance(workflow, InteractionWorkflow): not isinstance(workflow, InteractionWorkflow):
if state_id in workflow.getStateIdList(): if state_id in workflow.getStateIdList():
found = True found = True
...@@ -151,7 +151,7 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -151,7 +151,7 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool):
from Products.ERP5.InteractionWorkflow import InteractionWorkflowDefinition from Products.ERP5.InteractionWorkflow import InteractionWorkflowDefinition
from Products.ERP5Workflow.Document.InteractionWorkflow import InteractionWorkflow from Products.ERP5Workflow.Document.InteractionWorkflow import InteractionWorkflow
for workflow in (wf_id and (self[wf_id],) or self.getWorkflowValueListFor(ob.getPortalType())): for workflow in (wf_id and (self[wf_id],) or self.getWorkflowValueListFor(ob.getPortalType())):
if not isinstance(workflow, InteractionWorkflowDefinition) or \ if not isinstance(workflow, InteractionWorkflowDefinition) and \
not isinstance(workflow, InteractionWorkflow): not isinstance(workflow, InteractionWorkflow):
if state_id in workflow.getStateIdList(): if state_id in workflow.getStateIdList():
return True return True
...@@ -243,6 +243,24 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -243,6 +243,24 @@ class ERP5WorkflowTool(BaseTool, OriginalWorkflowTool):
workflow_list.append(wf) workflow_list.append(wf)
return workflow_list return workflow_list
security.declarePrivate('getHistoryOf')
def getHistoryOf(self, wf_id, ob):
""" Get the history of an object for a given workflow.
"""
if hasattr(aq_base(ob), 'workflow_history'):
wfh = ob.workflow_history
return wfh.get(wf_id, None)
return ()
security.declarePrivate('getStatusOf')
def getStatusOf(self, wf_id, ob):
""" Get the last element of a workflow history for a given workflow.
"""
wfh = self.getHistoryOf(wf_id, ob)
if wfh:
return wfh[-1]
return None
def dc_workflow_asERP5Object(self, container, dc_workflow, temp): def dc_workflow_asERP5Object(self, container, dc_workflow, temp):
# create a temporary ERP5 Workflow # create a temporary ERP5 Workflow
workflow_type_id = dc_workflow.__class__.__name__ workflow_type_id = dc_workflow.__class__.__name__
......
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