From d65092e9324262c4254a29f0868664627e52ba18 Mon Sep 17 00:00:00 2001
From: Fabien Morin <fabien@nexedi.com>
Date: Mon, 1 Jun 2009 10:00:04 +0000
Subject: [PATCH] add sorting

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27291 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/TradeCondition.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/product/ERP5/Document/TradeCondition.py b/product/ERP5/Document/TradeCondition.py
index b9364f47fa..73d75638b6 100644
--- a/product/ERP5/Document/TradeCondition.py
+++ b/product/ERP5/Document/TradeCondition.py
@@ -120,7 +120,6 @@ class TradeCondition(Path, Transformation):
       Reference of Trade Model Line is used to hide other Trade Model Line
       In chain first found Trade Model Line has precedence
       Context's, if not None, Trade Model Lines have precedence
-        XXX - the sorting is missing
       """
       visited_trade_condition_list = []
       def findSpecialiseValueList(context):
@@ -134,6 +133,9 @@ class TradeCondition(Path, Transformation):
           specialise_value_list.extend(findSpecialiseValueList(specialise))
         return specialise_value_list
 
+      def sortByIntIndex(a, b):
+        return cmp(a.getIntIndex(), b.getIntIndex())
+
       reference_list = []
       trade_model_line_composed_list = []
       containting_object_list = []
@@ -153,6 +155,8 @@ class TradeCondition(Path, Transformation):
           if reference not in reference_list:
             trade_model_line_composed_list.append(trade_model_line)
             reference_list.append(reference)
+
+      trade_model_line_composed_list.sort(sortByIntIndex)
       return trade_model_line_composed_list
 
     def getAggregatedAmountList(self, context, **kw):
-- 
2.30.9