diff --git a/product/ERP5/Document/BalanceTransaction.py b/product/ERP5/Document/BalanceTransaction.py
index db1bb2ed80dca4a26a994c12f31a8701bb12cdb5..a02d46e2cc119c81a2ee03740a164edd6b1de473 100644
--- a/product/ERP5/Document/BalanceTransaction.py
+++ b/product/ERP5/Document/BalanceTransaction.py
@@ -67,7 +67,7 @@ class InventoryKey(UserDict):
   def __cmp__(self, other):
     # this is basically here so that we can see if two inventory keys are
     # equals.
-    if tuple(self.keys()) != tuple(other.keys()):
+    if sorted(self.keys()) != sorted(other.keys()):
       return -1
     for k, v in self.items():
       if v != other[k]: