From 3c7fe462c24cd574246ff43dd48bc442c36ea2de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com> Date: Tue, 17 Jan 2012 15:52:18 +0100 Subject: [PATCH] Do not reinvent the wheel. --- product/ERP5/Document/SimulationMovement.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/product/ERP5/Document/SimulationMovement.py b/product/ERP5/Document/SimulationMovement.py index 0ee8b08d06..62fb223a8c 100644 --- a/product/ERP5/Document/SimulationMovement.py +++ b/product/ERP5/Document/SimulationMovement.py @@ -645,7 +645,6 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin): composed_document = self.asComposedDocument() predecessor_link_list = composed_document.getBusinessLinkValueList( successor=predecessor_state) - business_link_list = composed_document.getBusinessLinkValueList() def isBuiltAndCompleted(simulation, path): return simulation.getSimulationState() in path.getCompletedStateList() @@ -661,15 +660,15 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin): business_link = current.getCausality(portal_type='Business Link') if business_link is None: # no direct business link set on movement, use predicate to find one - for candidate_business_link in business_link_list: - if candidate_business_link.test(current): - if business_link is not None: - raise ValueError('Business Link predicate matches too many ' - 'movements.') - business_link = candidate_business_link.getRelativeUrl() - if not business_link: + business_link_list = composed_document.getBusinessLinkValueList( + context=current) + if len(business_link) == 0: + raise ValueError('Business Link predicate matches too many ' + 'movements.') + if len(business_link) > 1: raise ValueError('Simulation Movement has no Business Link related ' 'and no Business Link from current Business Process matches') + business_link = business_link_list[0].getRelativeUrl() causality_dict[business_link] = current current = current.getParentValue().getParentValue() -- 2.30.9