Commit 30f2582a authored by iv's avatar iv

ERP5Workflow: remove method doing accessor's job

parent 303bb9fc
......@@ -70,7 +70,7 @@ for ptype_id in type_workflow_dict:\n
# 2. assign ERP5 Workflow to portal type:\n
type_workflow_list = ptype.getTypeWorkflowList()\n
if workflow_id not in type_workflow_list:\n
ptype.addTypeWorkflowList(workflow_id)\n
ptype.setTypeWorkflowList(ptype.getTypeWorkflowList() + [workflow_id])\n
</string> </value>
</item>
<item>
......
......@@ -56,10 +56,6 @@ class PortalTypeClassInteractor(Interactor):
self.on(Localizer.del_language).doAfter(self.resetDynamic)
# New workflow compatibility
from Products.ERP5Type.ERP5Type import ERP5TypeInformation
self.on(ERP5TypeInformation.addTypeWorkflowList).doAfter(self.resetDynamic)
self.on(ERP5TypeInformation._edit).doAfter(self.resetDynamic)
from Products.ERP5Workflow.Document.Workflow import Workflow
self.on(Workflow._delObject).doAfter(self.resetDynamic)
self.on(Workflow._edit).doAfter(self.resetDynamic)
......
......@@ -451,14 +451,6 @@ class ERP5TypeInformation(XMLObject,
"""Getter for 'type_workflow' property"""
return list(self.workflow_list)
def delTypeWorkflowList(self, wf_id):
""" allow to modify workflow assignment from script. """
self.workflow_list = tuple(wf for wf in self.workflow_list if wf != wf_id)
def addTypeWorkflowList(self, wf_id):
""" allow to modify workflow assignment from script. """
self.workflow_list = self.workflow_list + (wf_id, )
def getTypePropertySheetValueList(self):
type_property_sheet_list = self.getTypePropertySheetList()
if not type_property_sheet_list:
......
......@@ -567,14 +567,18 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# type-workflow reassignment
type_workflow_dict = self.getChainsByType()
type_tool = self.getPortalObject().portal_types
for ptype_id in type_workflow_dict:
ptype = type_tool._getOb(ptype_id, None)
if ptype is not None and workflow_id in type_workflow_dict[ptype_id]:
# 1. clean DC workflow assignement:
self.delTypeCBT(ptype_id, workflow_id)
# 2. assign ERP5 Workflow to portal type:
if workflow_id not in ptype.getTypeWorkflowList():
ptype.addTypeWorkflowList(workflow_id)
type_workflow_list = ptype.getTypeWorkflowList()
if workflow_id not in workflow_list:
ptype.setTypeWorkflowList(
type_workflow_list + [workflow_id]
)
def reassignWorkflowWithoutConversion(self):
# This function should be called when a new template installed and add
......@@ -587,6 +591,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# be done, just go back to whatever you are doing.
type_workflow_dict = self.getChainsByType()
type_tool = self.getPortalObject().portal_types
erp5_workflow_list = []
for ptype_id in type_workflow_dict:
ptype = type_tool._getOb(ptype_id, None)
if ptype is not None:
......@@ -598,8 +603,9 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# 2. assign ERP5 Workflow to portal type:
type_workflow_list = ptype.getTypeWorkflowList()
if workflow_id not in type_workflow_list:
ptype.addTypeWorkflowList(workflow_id)
ptype.setTypeWorkflowList(
type_workflow_list + [workflow_id]
)
def getChainDict(self):
chain_dict = {}
for portal_type, wf_id_list in self._chains_by_type.iteritems():
......@@ -975,13 +981,19 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
def addWorkflowToType(self, type_value, wf_id_list):
# assign workflow(s) to a type
dc_wf_id_list = []
erp5_wf_id_list = []
for wf_id in wf_id_list:
wf_value = self._getOb(wf_id)
if self._getOb(wf_id).__class__.__name__ in ('DCWorkflowDefinition', 'InteractionWorkflowDefinition'):
dc_wf_id_list.append(wf_id)
else:
type_value.addTypeWorkflowList(wf_id)
if dc_wf_id_list != []:
erp5_wf_id_list.append(wf_id)
if erp5_wf_id_list:
type_value.setTypeWorkflowList(
type_value.getTypeWorkflowList() + erp5_wf_id_list
)
if dc_wf_id_list:
self.setChainForPortalTypes([type_value.id], tuple(dc_wf_id_list))
InitializeClass(WorkflowTool)
......
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