Commit af9d37e2 authored by wenjie.zheng's avatar wenjie.zheng

WorkflowTool.py: add reassignWorkflowWithoutConversion.

parent bf9cc762
......@@ -577,6 +577,30 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if workflow_id not in ptype.getTypeWorkflowList():
ptype.addTypeWorkflowList(workflow_id)
def reassignWorkflowWithoutConversion(self):
# This function should be called when a new template installed and add
# portal_types assignment with converted workflows in to _chain_by_type.
# This function only synchronize assignment information to new added portal
# type's TypeWorkflowList.
# To trigger this function, go to portal_workflow and choose "convert DCWorkflow"
# in the action list. Reassignment happens in the background. Nothing need to
# be done, just go back to whatever you are doing.
type_workflow_dict = self.getChainsByType()
for ptype_id in type_workflow_dict:
ptype = getattr(context.getPortalObject().portal_types, ptype_id, None)
if ptype is not None:
for workflow_id in type_workflow_dict[ptype_id]:
workflow = getattr(self, workflow_id, None)
if workflow and workflow.getPortalType() in ['Workflow', 'Interaction Workflow']:
# 1. clean DC workflow assignement:
self.delTypeCBT(ptype.id, workflow.id)
# 2. assign ERP5 Workflow to portal type:
type_workflow_list = ptype.getTypeWorkflowList()
if workflow_id not in type_workflow_list:
ptype.addTypeWorkflowList(workflow_id)
def getChainDict(self):
chain_dict = {}
for portal_type, wf_id_list in self._chains_by_type.iteritems():
......
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