Commit 5574bd63 authored by Ayush Tiwari's avatar Ayush Tiwari Committed by Ayush Tiwari

bt5_config: Override accessors for type_workflow_list property for ERP5TypeInformation

parent 155c8d4a
...@@ -228,7 +228,6 @@ class ERP5TypeInformation(XMLObject, ...@@ -228,7 +228,6 @@ class ERP5TypeInformation(XMLObject,
acquire_local_roles = False acquire_local_roles = False
property_sheet_list = () property_sheet_list = ()
base_category_list = () base_category_list = ()
workflow_list = ()
init_script = '' init_script = ''
product = 'ERP5Type' product = 'ERP5Type'
hidden_content_type_list = () hidden_content_type_list = ()
...@@ -335,22 +334,48 @@ class ERP5TypeInformation(XMLObject, ...@@ -335,22 +334,48 @@ class ERP5TypeInformation(XMLObject,
def getTypeInitScriptId(self): def getTypeInitScriptId(self):
return return
security.declareProtected(Permissions.ModifyPortalContent,
'getTypeWorkflowList')
def getTypeWorkflowList(self): def getTypeWorkflowList(self):
"""Getter for 'type_workflow' property""" """Getter for 'type_workflow_list' property"""
return list(self.workflow_list) pw = self.getPortalObject().portal_workflow
cbt = pw._chains_by_type
id = self.getId()
if cbt is not None and cbt.has_key(id):
workflow_list = list(cbt[id])
else:
workflow_list = ['(Default)',]
return workflow_list
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'setTypeWorkflowList') 'setTypeWorkflowList')
def setTypeWorkflowList(self, type_workflow_list): def _setTypeWorkflowList(self, type_workflow_list):
"""Setter for 'type_workflow' property""" """Override Setter for 'type_workflow' property"""
# We use 'sorted' below to keep an order in the workflow list. Without # We use setter to update the value for Workflow chain during the
# this line, the actions can have different order depending on the order # installation of Business Manager. This way, we would be able to
# set during the installation or later. This is bad! # modify workflow chain without the need of saving anything in
# It might not be the ideal solution, if you need to have the workflow # type_workflow_list property.
# defined in a specific order. Then, your new implementation should use
# indexes on workflows as in portal types action's priority. # If type_workflow_list is '(Default)', don't do/update anything
# Note: 'sorted' also convert a tuple or a set to a list if type_workflow_list[0] != '(Default)':
self.workflow_list = sorted(type_workflow_list) portal = self.getPortalObject()
pw = portal.portal_workflow
cbt = pw._chains_by_type
id = self.getId()
# If there is already key existing in cbt, then update it
if cbt is not None and cbt.has_key(id):
workflow_list = list(cbt(id))
# If the value in cbt is '(Default)', then update it only after removing
# default value
if workflow_list[0] != '(Default)':
type_workflow_list = type_workflow_list.extend(workflow_list)
cbt[id] = type_workflow_list
cbt[id] = sorted(type_workflow_list)
# Update the chains dictionary for portal_workflow
pw._chains_by_type = cbt
security.declarePrivate('_guessMethodAliases') security.declarePrivate('_guessMethodAliases')
def _guessMethodAliases(self): def _guessMethodAliases(self):
......
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