Commit cc18a344 authored by Julien Muchembled's avatar Julien Muchembled

ExplanationCache: do not create new business link closure if unnecessary

Also do not hardcode 'business_process_module'.
parent bdb5085a
...@@ -264,24 +264,31 @@ class ExplanationCache: ...@@ -264,24 +264,31 @@ class ExplanationCache:
path_list.sort() path_list.sort()
path_list = tuple(path_list) path_list = tuple(path_list)
new_business_process = self.closure_cache.get(path_list) new_business_process = self.closure_cache.get(path_list)
if new_business_process is not None: if new_business_process is None:
self.closure_cache[business_link] = new_business_process business_link_list = []
return new_business_process new_business_process = business_process
for x in business_process.getBusinessLinkValueList():
# Build a new closure business process if self.getSimulationMovementValueList(path=path_list,
module = business_process.getPortalObject().business_process_module # XXX-JPS causality_uid=x.getUid()):
self.closure_cache[business_link] = self.closure_cache[path_list] = \ # We have matching movements.
new_business_process = module.newContent(portal_type="Business Process", business_link_list.append(x)
temp_object=True) # XXX-JPS is this really OK with union business processes else:
i = 0 new_business_process = None
for business_link in business_process.getBusinessLinkValueList(): if new_business_process is None:
if self.getSimulationMovementValueList(path=path_list, # Build a new closure business process.
causality_uid=business_link.getUid()): # Initially, business_process is often the result of
# We have matching movements. # asComposedDocument() and business_process.getParentValue() is not a
i += 1 # module where newContent() allows creation of Business Processes.
id = 'closure_path_%s' % i # XXX-JPS is this really OK with union business processes
new_business_process._setOb(id, business_link.asContext(id=id)) from Products.ERP5Type.Document import newTempBusinessProcess
new_business_process = newTempBusinessProcess(
self.explanation, 'closure_business_process')
for i, x in enumerate(business_link_list):
id = 'closure_path_%s' % i
new_business_process._setOb(id, x.asContext(id=id))
self.closure_cache[path_list] = new_business_process
self.closure_cache[business_link] = new_business_process
return new_business_process return new_business_process
def getUnionBusinessProcess(self): def getUnionBusinessProcess(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