From 87c6d131b2f0a24a2d55dc5c5611bb565d3c7b0b Mon Sep 17 00:00:00 2001 From: Ayush Tiwari <ayush.tiwari@nexedi.com> Date: Tue, 1 Aug 2017 12:10:54 +0000 Subject: [PATCH] bt5_config: Override accessors for type_workflow_list accroding to need for portal_workflow chain bootstrap --- product/ERP5Type/ERP5Type.py | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py index 9823eab905..87016fa639 100644 --- a/product/ERP5Type/ERP5Type.py +++ b/product/ERP5Type/ERP5Type.py @@ -343,9 +343,16 @@ class ERP5TypeInformation(XMLObject, if cbt is not None and cbt.has_key(id): workflow_list = list(cbt[id]) else: - workflow_list = ['(Default)',] + workflow_list = None return workflow_list + def hasTypeWorkflowList(self): + """ + Always return True. Overriden as general accessor is generated after the + use of this function while installing Business Manager + """ + return True + security.declareProtected(Permissions.ModifyPortalContent, 'setTypeWorkflowList') def _setTypeWorkflowList(self, type_workflow_list): @@ -354,25 +361,32 @@ class ERP5TypeInformation(XMLObject, # installation of Business Manager. This way, we would be able to # modify workflow chain without the need of saving anything in # type_workflow_list property. + portal = self.getPortalObject() + pw = portal.portal_workflow + cbt = pw._chains_by_type + id = self.getId() + + # If the type_workflow_list is empty, delete the key from workflow chains + if not type_workflow_list: + cbt[id] = [] + pw._chains_by_type = cbt # If type_workflow_list is '(Default)', don't do/update anything - if type_workflow_list[0] != '(Default)': - portal = self.getPortalObject() - pw = portal.portal_workflow - cbt = pw._chains_by_type - id = self.getId() + elif type_workflow_list[0] != '(Default)': # 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)) + workflow_list = list(cbt[id]) + + if not workflow_list: + cbt[id] = sorted(type_workflow_list) # If the value in cbt is '(Default)', then update it only after removing # default value - if workflow_list[0] != '(Default)': + elif workflow_list[0] != '(Default)': type_workflow_list = type_workflow_list.extend(workflow_list) - cbt[id] = type_workflow_list + cbt[id] = sorted(type_workflow_list) - cbt[id] = sorted(type_workflow_list) # Update the chains dictionary for portal_workflow pw._chains_by_type = cbt -- 2.30.9