From e603317854321939f1b21691ec3f20961e97461c Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet <nicolas.dumazet@nexedi.com> Date: Fri, 4 Jun 2010 03:28:49 +0000 Subject: [PATCH] walk supply line list once instead of thrice git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35978 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/SupplyChain.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/product/ERP5/Document/SupplyChain.py b/product/ERP5/Document/SupplyChain.py index ce52755cd9..e0496031e2 100644 --- a/product/ERP5/Document/SupplyChain.py +++ b/product/ERP5/Document/SupplyChain.py @@ -97,16 +97,18 @@ class SupplyChain(Path, XMLObject): portal_type=self.supply_link_portal_type) # Search next link next_node_value = current_supply_link.getNextNodeValue() - next_supply_link_list = [x for x in supply_link_list if \ - x.getCurrentNodeValue() == next_node_value] - # Prevent infinite loop - if current_supply_link in next_supply_link_list: - next_supply_link_list.remove(current_supply_link) - # Get only production node in the list, or return the entire list - next_production_list = [x for x in next_supply_link_list \ - if x.isProductionSupplyLink()] + + next_supply_link_list = [] + next_production_list = [] + for supply_link in supply_link_list: + if supply_link != current_supply_link and \ + supply_link.getCurrentNodeValue() == next_node_value: + next_supply_link_list.append(supply_link) + if supply_link.isProductionSupplyLink(): + next_production_list.append(supply_link) + if next_production_list != []: - next_supply_link_list = next_production_list + return next_production_list return next_supply_link_list security.declareProtected(Permissions.View, -- 2.30.9