Commit c757558f authored by Alexandre Boeglin's avatar Alexandre Boeglin

Cleaned duplicate code.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2940 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5be92456
...@@ -445,17 +445,14 @@ class SimulationTool (BaseTool): ...@@ -445,17 +445,14 @@ class SimulationTool (BaseTool):
""" """
sql_kw = self._generateSQLKeywordDict(**kw) sql_kw = self._generateSQLKeywordDict(**kw)
if src__ : result = self.Resource_zGetInventory(src__=src__,
return self.Resource_zGetInventory(src__=1,
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)
result = self.Resource_zGetInventory(
ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation, ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output, omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report, **sql_kw) selection_domain=selection_domain, selection_report=selection_report, **sql_kw)
if len(result) > 0: if src__ :
return result
if len(result) > 0 and result[0].inventory is not None :
return result[0].inventory return result[0].inventory
return 0.0 return 0.0
...@@ -494,13 +491,7 @@ class SimulationTool (BaseTool): ...@@ -494,13 +491,7 @@ class SimulationTool (BaseTool):
""" """
sql_kw = self._generateSQLKeywordDict(**kw) sql_kw = self._generateSQLKeywordDict(**kw)
if src__ : return self.Resource_zGetInventoryList(src__=src__,
return self.Resource_zGetInventoryList(src__=1,
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)
return self.Resource_zGetInventoryList(
ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation, ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output, omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report, **sql_kw) selection_domain=selection_domain, selection_report=selection_report, **sql_kw)
...@@ -531,13 +522,7 @@ class SimulationTool (BaseTool): ...@@ -531,13 +522,7 @@ class SimulationTool (BaseTool):
""" """
sql_kw = self._generateSQLKeywordDict(**kw) sql_kw = self._generateSQLKeywordDict(**kw)
if src__ : return self.Resource_zGetInventory(src__=src__,
return self.Resource_zGetInventory(src__=1,
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)
return self.Resource_zGetInventory(
ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation, ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output, omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report, **sql_kw) selection_domain=selection_domain, selection_report=selection_report, **sql_kw)
...@@ -560,14 +545,14 @@ class SimulationTool (BaseTool): ...@@ -560,14 +545,14 @@ class SimulationTool (BaseTool):
return self.getInventoryStat(**kw) return self.getInventoryStat(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryChart')
def getInventoryChart(self, **kw): def getInventoryChart(self, src__=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
result = self.getInventoryList(src__=src__, **kw)
if src__ : if src__ :
return self.getInventoryList(src__=1, **kw) return result
result = self.getInventoryList(**kw)
return map(lambda r: (r.node_title, r.inventory), result) return map(lambda r: (r.node_title, r.inventory), result)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryChart')
...@@ -596,13 +581,7 @@ class SimulationTool (BaseTool): ...@@ -596,13 +581,7 @@ class SimulationTool (BaseTool):
""" """
sql_kw = self._generateSQLKeywordDict(**kw) sql_kw = self._generateSQLKeywordDict(**kw)
if src__ : return self.Resource_zGetInventoryAssetPrice(src__=src__,
return self.Resource_zGetInventoryAssetPrice(src__=1,
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)
return self.Resource_zGetInventoryAssetPrice(
ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation, ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output, omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report, **sql_kw) selection_domain=selection_domain, selection_report=selection_report, **sql_kw)
...@@ -642,13 +621,7 @@ class SimulationTool (BaseTool): ...@@ -642,13 +621,7 @@ class SimulationTool (BaseTool):
""" """
sql_kw = self._generateSQLKeywordDict(**kw) sql_kw = self._generateSQLKeywordDict(**kw)
if src__ : return self.Resource_getInventoryHistoryList(src__=src__,
return self.Resource_getInventoryHistoryList(src__=1,
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)
return self.Resource_getInventoryHistoryList(
ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation, ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output, omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report, **sql_kw) selection_domain=selection_domain, selection_report=selection_report, **sql_kw)
...@@ -662,13 +635,7 @@ class SimulationTool (BaseTool): ...@@ -662,13 +635,7 @@ class SimulationTool (BaseTool):
""" """
sql_kw = self._generateSQLKeywordDict(**kw) sql_kw = self._generateSQLKeywordDict(**kw)
if src__ : return self.Resource_getInventoryHistoryChart(src__=src__,
return self.Resource_getInventoryHistoryChart(src__=1,
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)
return self.Resource_getInventoryHistoryChart(
ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation, ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output, omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report, **sql_kw) selection_domain=selection_domain, selection_report=selection_report, **sql_kw)
...@@ -682,13 +649,7 @@ class SimulationTool (BaseTool): ...@@ -682,13 +649,7 @@ class SimulationTool (BaseTool):
""" """
sql_kw = self._generateSQLKeywordDict(**kw) sql_kw = self._generateSQLKeywordDict(**kw)
if src__ : return self.Resource_zGetMovementHistoryList(src__=src__,
return self.Resource_zGetMovementHistoryList(src__=1,
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)
return self.Resource_zGetMovementHistoryList(
ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation, ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output, omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report, **sql_kw) selection_domain=selection_domain, selection_report=selection_report, **sql_kw)
...@@ -702,13 +663,7 @@ class SimulationTool (BaseTool): ...@@ -702,13 +663,7 @@ class SimulationTool (BaseTool):
""" """
sql_kw = self._generateSQLKeywordDict(**kw) sql_kw = self._generateSQLKeywordDict(**kw)
if src__ : return self.Resource_zGetInventory(src__=src__,
return self.Resource_zGetInventory(src__=1,
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)
return self.Resource_zGetInventory(
ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation, ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output, omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report, **sql_kw) selection_domain=selection_domain, selection_report=selection_report, **sql_kw)
...@@ -722,21 +677,16 @@ class SimulationTool (BaseTool): ...@@ -722,21 +677,16 @@ class SimulationTool (BaseTool):
""" """
sql_kw = self._generateSQLKeywordDict(**kw) sql_kw = self._generateSQLKeywordDict(**kw)
if src__ : result = self.Resource_getInventoryHistoryList(src__=src__,
return self.Resource_getInventoryHistoryList(src__=1,
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)
result = self.Resource_getInventoryHistoryList(
ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation, ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output, omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report, **sql_kw) selection_domain=selection_domain, selection_report=selection_report, **sql_kw)
if src__ :
return result
for inventory in result: for inventory in result:
if inventory['inventory'] < 0: if inventory['inventory'] < 0:
return inventory['stop_date'] return inventory['stop_date']
return None return None
####################################################### #######################################################
...@@ -768,13 +718,7 @@ class SimulationTool (BaseTool): ...@@ -768,13 +718,7 @@ class SimulationTool (BaseTool):
""" """
sql_kw = self._generateSQLKeywordDict(**kw) sql_kw = self._generateSQLKeywordDict(**kw)
if src__ : return self.Resource_zGetTrackingList(src__=src__,
return self.Resource_zGetTrackingList(src__=1,
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)
return self.Resource_zGetTrackingList(
ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation, ignore_variation=ignore_variation, standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output, omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report, **sql_kw) selection_domain=selection_domain, selection_report=selection_report, **sql_kw)
......
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