Commit fd68f6a4 authored by Nicolas Dumazet's avatar Nicolas Dumazet

one iteration over supply_link_list instead of three list comprehensions


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35976 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1e0d3a7a
......@@ -140,28 +140,29 @@ class SupplyChain(Path, XMLObject):
"""
Return the previous SupplyLink list.
"""
if current_supply_link is not None:
if current_supply_link is None:
# No current_supply_link defined, we need to return the last SupplyLink
return [self.getLastLink()]
else:
# Get all SupplyLink in the SupplyChain
supply_link_list = self.objectValues(
portal_type=self.supply_link_portal_type)
# Destination of valid link must be the source of the current link.
current_node_value = current_supply_link.getCurrentNodeValue()
previous_supply_link_list = [
x for x in supply_link_list if\
x.getNextNodeValue() == current_node_value]
# Prevent infinite loop
if current_supply_link in previous_supply_link_list:
previous_supply_link_list.remove(current_supply_link)
# Get only production node in the list, or return the entire list
previous_production_list = [x for x in previous_supply_link_list\
if x.isProductionSupplyLink()]
previous_supply_link_list = []
previous_production_list = []
for supply_link in supply_link_list:
if supply_link != current_supply_link and \
supply_link.getNextNodeValue() == current_node_value:
previous_supply_link_list.append(supply_link)
if supply_link.isProductionSupplyLink():
previous_production_list.append(supply_link)
if previous_production_list != []:
previous_supply_link_list = previous_production_list
else:
# No current_supply_link defined, we need to return the last SupplyLink
previous_supply_link_list = [self.getLastLink()]
# Return result
return previous_supply_link_list
return previous_supply_link_list
security.declareProtected(Permissions.View,
'getPreviousProductionSupplyLinkList')
......
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