From bc3c7d45e16fa864401f471854dd417459331d11 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 25 Jan 2006 09:33:48 +0000
Subject: [PATCH] merge getInventoryAssetPrice with getInventory implementation

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

diff --git a/product/ERP5/Tool/SimulationTool.py b/product/ERP5/Tool/SimulationTool.py
index c0ac09c599..825fffe7b4 100755
--- a/product/ERP5/Tool/SimulationTool.py
+++ b/product/ERP5/Tool/SimulationTool.py
@@ -613,16 +613,24 @@ class SimulationTool (BaseTool):
       Same thing as getInventory but returns an asset 
       price rather than an inventory.
       
-      NOTE: implementation could be merged with getInventory
       """
       sql_kw = self._generateSQLKeywordDict(**kw)
+      result = self.Resource_zGetInventory(
+          src__=src__, ignore_variation=ignore_variation,
+          standardise=standardise, omit_simulation=omit_simulation,
+          omit_input=omit_input, omit_output=omit_output,
+          selection_domain=selection_domain, selection_report=selection_report,
+          **sql_kw)
+      if src__ :
+        return result
 
-      return self.Resource_zGetInventoryAssetPrice(
-                     src__=src__, ignore_variation=ignore_variation, 
-                     standardise=standardise, omit_simulation=omit_simulation,
-                     omit_input=omit_input, omit_output=omit_output,
-                     selection_domain=selection_domain, 
-                     selection_report=selection_report, **sql_kw)
+      total_result = 0.0
+      if len(result) > 0:
+        for result_line in result:
+          if result_line.inventory is not None:
+            total_result += result_line.total_price
+      
+      return total_result
 
     security.declareProtected(Permissions.AccessContentsInformation, 
                               'getCurrentInventoryAssetPrice')
-- 
2.30.9