From 8d8a3cbfc4712637306a96b3470c57e17650bf6c Mon Sep 17 00:00:00 2001
From: Alexandre Boeglin <alex@nexedi.com>
Date: Mon, 13 Jun 2005 12:15:11 +0000
Subject: [PATCH] Using GROUP_BY in the query might return multiple lines.
 getInventory must return the total sum.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3246 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Tool/SimulationTool.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/product/ERP5/Tool/SimulationTool.py b/product/ERP5/Tool/SimulationTool.py
index 68272a727a..da43907999 100755
--- a/product/ERP5/Tool/SimulationTool.py
+++ b/product/ERP5/Tool/SimulationTool.py
@@ -492,9 +492,13 @@ class SimulationTool (BaseTool):
       if src__ :
         return result
 
-      if len(result) > 0 and result[0].inventory is not None :
-        return result[0].inventory
-      return 0.0
+      total_result = 0.0
+      if len(result) > 0:
+        for result_line in result:
+          if result_line.inventory is not None:
+            total_result += result_line.inventory
+
+      return total_result
 
     security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory')
     def getCurrentInventory(self, **kw):
-- 
2.30.9