Commit 9cc5cfd1 authored by Jérome Perrin's avatar Jérome Perrin

I was wrong, we never wanted to drop omit_simulation support.

Add tests for omit_simulation



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9784 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6b696094
......@@ -27,8 +27,6 @@
#
##############################################################################
from warnings import warn
from Products.CMFCore.utils import getToolByName
from AccessControl import ClassSecurityInfo
......@@ -48,8 +46,6 @@ from DateTime import DateTime
from Products.ERP5 import DeliverySolver
from Products.ERP5 import TargetSolver
_marker_for_depreacated_argument = []
class SimulationTool (BaseTool):
"""
The SimulationTool implements the ERP5
......@@ -462,8 +458,7 @@ class SimulationTool (BaseTool):
security.declareProtected(Permissions.AccessContentsInformation,
'getInventory')
def getInventory(self, src__=0, ignore_variation=0, standardise=0,
omit_simulation=_marker_for_depreacated_argument,
omit_input=0, omit_output=0,
omit_simulation=0, omit_input=0, omit_output=0,
selection_domain=None, selection_report=None, **kw):
"""
Returns an inventory of a single or multiple resources on a single or multiple
......@@ -518,6 +513,8 @@ class SimulationTool (BaseTool):
standardise - provide a standard quantity rather than an SKU (XXX not implemented yet)
omit_simulation - doesn't take into account simulation movements
omit_input
omit_output
......@@ -538,14 +535,11 @@ class SimulationTool (BaseTool):
NOTE: we may want to define a parameter so that we can select the kind of inventory
statistics we want to display (ex. sum, average, cost, etc.)
"""
if omit_simulation is not _marker_for_depreacated_argument:
warn('omit_simulation parameter is ignored', DeprecationWarning)
sql_kw = self._generateSQLKeywordDict(**kw)
result = self.Resource_zGetInventory(
src__=src__, ignore_variation=ignore_variation,
standardise=standardise,
standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report,
**sql_kw)
......@@ -598,8 +592,7 @@ class SimulationTool (BaseTool):
security.declareProtected(Permissions.AccessContentsInformation,
'getInventoryList')
def getInventoryList(self, src__=0, ignore_variation=0, standardise=0,
omit_simulation=_marker_for_depreacated_argument,
omit_input=0, omit_output=0,
omit_simulation=0, omit_input=0, omit_output=0,
selection_domain=None, selection_report=None, **kw):
"""
Returns a list of inventories for a single or multiple
......@@ -610,13 +603,10 @@ class SimulationTool (BaseTool):
the kind of inventory statistics we want to display (ex. sum,
average, cost, etc.)
"""
if omit_simulation is not _marker_for_depreacated_argument:
warn('omit_simulation parameter is ignored', DeprecationWarning)
sql_kw = self._generateSQLKeywordDict(**kw)
return self.Resource_zGetInventoryList(
src__=src__, ignore_variation=ignore_variation,
standardise=standardise,
standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain,
selection_report=selection_report, **sql_kw)
......@@ -656,8 +646,7 @@ class SimulationTool (BaseTool):
security.declareProtected(Permissions.AccessContentsInformation,
'getInventoryStat')
def getInventoryStat(self, src__=0, ignore_variation=0, standardise=0,
omit_simulation=_marker_for_depreacated_argument,
omit_input=0, omit_output=0,
omit_simulation=0, omit_input=0, omit_output=0,
selection_domain=None, selection_report=None, **kw):
"""
getInventoryStat is the pending to getInventoryList in order to
......@@ -665,14 +654,11 @@ class SimulationTool (BaseTool):
total of inventories, number of variations, number of different
nodes, etc.
"""
if omit_simulation is not _marker_for_depreacated_argument:
warn('omit_simulation parameter is ignored', DeprecationWarning)
kw['group_by_variation'] = 0
sql_kw = self._generateSQLKeywordDict(**kw)
result = self.Resource_zGetInventory(
src__=src__, ignore_variation=ignore_variation,
standardise=standardise,
standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain,
selection_report=selection_report, **sql_kw)
......@@ -751,9 +737,7 @@ class SimulationTool (BaseTool):
security.declareProtected(Permissions.AccessContentsInformation,
'getInventoryAssetPrice')
def getInventoryAssetPrice(self, src__=0, ignore_variation=0,
standardise=0,
omit_simulation=_marker_for_depreacated_argument,
omit_input=0,
standardise=0, omit_simulation=0, omit_input=0,
omit_output=0, selection_domain=None,
selection_report=None, **kw):
"""
......@@ -761,13 +745,10 @@ class SimulationTool (BaseTool):
price rather than an inventory.
"""
if omit_simulation is not _marker_for_depreacated_argument:
warn('omit_simulation parameter is ignored', DeprecationWarning)
sql_kw = self._generateSQLKeywordDict(**kw)
result = self.Resource_zGetInventory(
src__=src__, ignore_variation=ignore_variation,
standardise=standardise,
standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain, selection_report=selection_report,
**sql_kw)
......@@ -818,9 +799,7 @@ class SimulationTool (BaseTool):
security.declareProtected(Permissions.AccessContentsInformation,
'getInventoryHistoryList')
def getInventoryHistoryList(self, src__=0, ignore_variation=0,
standardise=0,
omit_simulation=_marker_for_depreacated_argument,
omit_input=0,
standardise=0, omit_simulation=0, omit_input=0,
omit_output=0, selection_domain=None,
selection_report=None, **kw):
"""
......@@ -828,13 +807,10 @@ class SimulationTool (BaseTool):
for a single or a group of resource, node, section, etc. This is useful
to list the evolution with time of inventory values (quantity, asset price).
"""
if omit_simulation is not _marker_for_depreacated_argument:
warn('omit_simulation parameter is ignored', DeprecationWarning)
sql_kw = self._generateSQLKeywordDict(**kw)
return self.Resource_getInventoryHistoryList(
src__=src__, ignore_variation=ignore_variation,
standardise=standardise,
standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain,
selection_report=selection_report, **sql_kw)
......@@ -842,8 +818,7 @@ class SimulationTool (BaseTool):
security.declareProtected(Permissions.AccessContentsInformation,
'getInventoryHistoryChart')
def getInventoryHistoryChart(self, src__=0, ignore_variation=0,
standardise=0,
omit_simulation=_marker_for_depreacated_argument,
standardise=0, omit_simulation=0,
omit_input=0, omit_output=0,
selection_domain=None,
selection_report=None, **kw):
......@@ -854,14 +829,11 @@ class SimulationTool (BaseTool):
time, value and "colour" (multiple graphs can be drawn for example
for each variation of a resource)
"""
if omit_simulation is not _marker_for_depreacated_argument:
warn('omit_simulation parameter is ignored', DeprecationWarning)
sql_kw = self._generateSQLKeywordDict(**kw)
return self.Resource_getInventoryHistoryChart(
src__=src__, ignore_variation=ignore_variation,
standardise=standardise,
standardise=standardise, omit_simulation=omit_simulation,
omit_input=omit_input, omit_output=omit_output,
selection_domain=selection_domain,
selection_report=selection_report, **sql_kw)
......@@ -869,8 +841,7 @@ class SimulationTool (BaseTool):
security.declareProtected(Permissions.AccessContentsInformation,
'getMovementHistoryList')
def getMovementHistoryList(self, src__=0, ignore_variation=0,
standardise=0,
omit_simulation=_marker_for_depreacated_argument,
standardise=0, omit_simulation=0,
omit_input=0, omit_output=0,
selection_domain=None, selection_report=None,
**kw):
......@@ -878,13 +849,11 @@ class SimulationTool (BaseTool):
Returns a list of movements which modify the inventory
for a single or a group of resource, node, section, etc.
"""
if omit_simulation is not _marker_for_depreacated_argument:
warn('omit_simulation parameter is ignored', DeprecationWarning)
sql_kw = self._generateSQLKeywordDict(**kw)
return self.Resource_zGetMovementHistoryList(
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)
......@@ -892,48 +861,35 @@ class SimulationTool (BaseTool):
security.declareProtected(Permissions.AccessContentsInformation,
'getMovementHistoryStat')
def getMovementHistoryStat(self, src__=0, ignore_variation=0,
standardise=0,
omit_simulation=_marker_for_depreacated_argument,
omit_input=0,
standardise=0, omit_simulation=0, omit_input=0,
omit_output=0, selection_domain=None,
selection_report=None, **kw):
"""
getMovementHistoryStat is the pending to getMovementHistoryList
for ListBox stat
"""
if omit_simulation is not _marker_for_depreacated_argument:
warn('omit_simulation parameter is ignored', DeprecationWarning)
sql_kw = self._generateSQLKeywordDict(**kw)
return self.Resource_zGetInventory(src__=src__,
ignore_variation=ignore_variation, standardise=standardise,
omit_input=omit_input,
omit_simulation=omit_simulation, omit_input=omit_input,
omit_output=omit_output, selection_domain=selection_domain,
selection_report=selection_report, **sql_kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getNextNegativeInventoryDate')
security.declareProtected(Permissions.AccessContentsInformation, 'getNextNegativeInventoryDate')
def getNextNegativeInventoryDate(self, src__=0,
ignore_variation=0, standardise=0,
omit_simulation=_marker_for_depreacated_argument,
omit_input=0, omit_output=0,
ignore_variation=0, standardise=0, omit_simulation=0, omit_input=0, omit_output=0,
selection_domain=None, selection_report=None, **kw):
"""
Returns statistics of inventory grouped by section or site
"""
if omit_simulation is not _marker_for_depreacated_argument:
warn('omit_simulation parameter is ignored', DeprecationWarning)
sql_kw = self._generateSQLKeywordDict(
order_by_expression='stock.date', **kw)
sql_kw = self._generateSQLKeywordDict(order_by_expression='stock.date', **kw)
sql_kw['group_by_expression'] = 'stock.uid'
sql_kw['order_by_expression'] = 'stock.date'
result = self.Resource_zGetInventory(src__=src__,
ignore_variation=ignore_variation, standardise=standardise,
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)
selection_domain=selection_domain, selection_report=selection_report, **sql_kw)
if src__ :
return result
......@@ -948,8 +904,7 @@ class SimulationTool (BaseTool):
#######################################################
# Traceability management
security.declareProtected(Permissions.AccessContentsInformation,
'getTrackingList')
security.declareProtected(Permissions.AccessContentsInformation, 'getTrackingList')
def getTrackingList(self, src__=0,
selection_domain=None, selection_report=None,
strict_simulation_state=1, **kw) :
......@@ -1027,17 +982,14 @@ class SimulationTool (BaseTool):
delivered for the last time before at_date or to_date". Cannot be used with input
"""
new_kw = self._generateSQLKeywordDict(table='item',
strict_simulation_state=strict_simulation_state,
**kw)
new_kw = self._generateSQLKeywordDict(table='item',strict_simulation_state=strict_simulation_state,**kw)
new_kw['at_date'] = kw.get('at_date')
# Extra parameters for the SQL Method
new_kw['join_on_item'] = new_kw.get('at_date') or \
new_kw.get('input') or \
new_kw.get('output')
new_kw['date_condition_in_join'] = not (new_kw.get('input')
or new_kw.get('output'))
new_kw['date_condition_in_join'] = not (new_kw.get('input') or new_kw.get('output'))
# Pass simulation state to request
if kw.has_key('item.simulation_state'):
......
......@@ -78,6 +78,12 @@
<dictionary/>
</value>
</item>
<item>
<key> <string>omit_simulation</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>order_by_expression</string> </key>
<value>
......@@ -126,18 +132,19 @@
<key> <string>_keys</string> </key>
<value>
<list>
<string>from_table_list</string>
<string>where_expression</string>
<string>order_by_expression</string>
<string>selection_domain</string>
<string>selection_report</string>
<string>ignore_variation</string>
<string>standardize</string>
<string>omit_input</string>
<string>omit_output</string>
<string>input_simulation_state</string>
<string>output_simulation_state</string>
<string>group_by_expression</string>
<string>from_table_list</string>
<string>where_expression</string>
<string>order_by_expression</string>
<string>selection_domain</string>
<string>selection_report</string>
<string>ignore_variation</string>
<string>standardize</string>
<string>omit_simulation</string>
<string>omit_input</string>
<string>omit_output</string>
<string>input_simulation_state</string>
<string>output_simulation_state</string>
<string>group_by_expression</string>
</list>
</value>
</item>
......@@ -167,6 +174,7 @@ selection_domain\r\n
selection_report\r\n
ignore_variation\r\n
standardize\r\n
omit_simulation\r\n
omit_input\r\n
omit_output\r\n
input_simulation_state:list\r\n
......@@ -249,6 +257,10 @@ WHERE\n
AND node.uid = stock.node_uid\n
AND resource.uid = stock.resource_uid\n
\n
<dtml-if omit_simulation>\n
AND catalog.portal_type != \'Simulation Movement\'\n
</dtml-if>\n
\n
<dtml-if omit_input>\n
AND stock.quantity < 0\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
......@@ -375,6 +387,10 @@ WHERE\n
AND node.uid = stock.node_uid\n
AND resource.uid = stock.resource_uid\n
\n
<dtml-if omit_simulation>\n
AND catalog.portal_type != \'Simulation Movement\'\n
</dtml-if>\n
\n
<dtml-if omit_input>\n
AND stock.quantity < 0\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
......
......@@ -86,6 +86,12 @@
<dictionary/>
</value>
</item>
<item>
<key> <string>omit_simulation</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>order_by_expression</string> </key>
<value>
......@@ -134,18 +140,19 @@
<key> <string>_keys</string> </key>
<value>
<list>
<string>from_table_list</string>
<string>where_expression</string>
<string>order_by_expression</string>
<string>group_by_expression</string>
<string>selection_domain</string>
<string>selection_report</string>
<string>ignore_variation</string>
<string>standardize</string>
<string>omit_input</string>
<string>omit_output</string>
<string>input_simulation_state</string>
<string>output_simulation_state</string>
<string>from_table_list</string>
<string>where_expression</string>
<string>order_by_expression</string>
<string>group_by_expression</string>
<string>selection_domain</string>
<string>selection_report</string>
<string>ignore_variation</string>
<string>standardize</string>
<string>omit_simulation</string>
<string>omit_input</string>
<string>omit_output</string>
<string>input_simulation_state</string>
<string>output_simulation_state</string>
</list>
</value>
</item>
......@@ -176,6 +183,7 @@ selection_domain\r\n
selection_report\r\n
ignore_variation\r\n
standardize\r\n
omit_simulation\r\n
omit_input\r\n
omit_output\r\n
input_simulation_state:list\r\n
......@@ -258,6 +266,10 @@ WHERE\n
AND node.uid = stock.node_uid\n
AND resource.uid = stock.resource_uid\n
\n
<dtml-if omit_simulation>\n
AND catalog.portal_type != \'Simulation Movement\'\n
</dtml-if>\n
\n
<dtml-if omit_input>\n
AND stock.quantity < 0\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
......@@ -391,6 +403,10 @@ WHERE\n
AND node.uid = stock.node_uid\n
AND resource.uid = stock.resource_uid\n
\n
<dtml-if omit_simulation>\n
AND catalog.portal_type != \'Simulation Movement\'\n
</dtml-if>\n
\n
<dtml-if omit_input>\n
AND stock.quantity < 0\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
......
......@@ -78,6 +78,12 @@
<dictionary/>
</value>
</item>
<item>
<key> <string>omit_simulation</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>order_by_expression</string> </key>
<value>
......@@ -126,18 +132,19 @@
<key> <string>_keys</string> </key>
<value>
<list>
<string>from_table_list</string>
<string>where_expression</string>
<string>order_by_expression</string>
<string>group_by_expression</string>
<string>selection_domain</string>
<string>selection_report</string>
<string>ignore_variation</string>
<string>standardize</string>
<string>omit_input</string>
<string>omit_output</string>
<string>input_simulation_state</string>
<string>output_simulation_state</string>
<string>from_table_list</string>
<string>where_expression</string>
<string>order_by_expression</string>
<string>group_by_expression</string>
<string>selection_domain</string>
<string>selection_report</string>
<string>ignore_variation</string>
<string>standardize</string>
<string>omit_simulation</string>
<string>omit_input</string>
<string>omit_output</string>
<string>input_simulation_state</string>
<string>output_simulation_state</string>
</list>
</value>
</item>
......@@ -577,6 +584,7 @@ selection_domain\r\n
selection_report\r\n
ignore_variation\r\n
standardize\r\n
omit_simulation\r\n
omit_input\r\n
omit_output\r\n
input_simulation_state:list\r\n
......@@ -656,6 +664,10 @@ WHERE\n
AND node.uid = stock.node_uid\n
AND resource.uid = stock.resource_uid\n
\n
<dtml-if omit_simulation>\n
AND catalog.portal_type != \'Simulation Movement\'\n
</dtml-if>\n
\n
<dtml-if omit_input>\n
AND stock.quantity < 0\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
......@@ -786,6 +798,10 @@ WHERE\n
AND node.uid = stock.node_uid\n
AND resource.uid = stock.resource_uid\n
\n
<dtml-if omit_simulation>\n
AND catalog.portal_type != \'Simulation Movement\'\n
</dtml-if>\n
\n
<dtml-if omit_input>\n
AND stock.quantity < 0\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
......
......@@ -76,6 +76,12 @@
<dictionary/>
</value>
</item>
<item>
<key> <string>omit_simulation</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>query</string> </key>
<value>
......@@ -152,21 +158,22 @@
<key> <string>_keys</string> </key>
<value>
<list>
<string>query</string>
<string>resource_uid</string>
<string>from_date</string>
<string>at_date</string>
<string>to_date</string>
<string>omit_input</string>
<string>omit_output</string>
<string>simulation_state</string>
<string>section_category</string>
<string>selection_domain</string>
<string>selection_report</string>
<string>closed_summary</string>
<string>where_expression</string>
<string>from_table_list</string>
<string>selection_uids</string>
<string>query</string>
<string>resource_uid</string>
<string>from_date</string>
<string>at_date</string>
<string>to_date</string>
<string>omit_simulation</string>
<string>omit_input</string>
<string>omit_output</string>
<string>simulation_state</string>
<string>section_category</string>
<string>selection_domain</string>
<string>selection_report</string>
<string>closed_summary</string>
<string>where_expression</string>
<string>from_table_list</string>
<string>selection_uids</string>
</list>
</value>
</item>
......@@ -194,6 +201,7 @@ resource_uid:list\r\n
from_date\r\n
at_date\r\n
to_date\r\n
omit_simulation\r\n
omit_input\r\n
omit_output\r\n
simulation_state:list\r\n
......@@ -295,6 +303,9 @@ WHERE\n
<dtml-if to_date>\n
AND stock.date < <dtml-sqlvar to_date type="datetime">\n
</dtml-if>\n
<dtml-if omit_simulation>\n
AND catalog.portal_type != \'Simulation Movement\'\n
</dtml-if>\n
<dtml-if omit_input>\n
AND stock.quantity < 0\n
AND (stock.node_uid <> stock.mirror_node_uid\n
......@@ -435,6 +446,9 @@ WHERE\n
<dtml-if to_date>\n
AND stock.date < <dtml-sqlvar to_date type="datetime">\n
</dtml-if>\n
<dtml-if omit_simulation>\n
AND catalog.portal_type != \'Simulation Movement\'\n
</dtml-if>\n
<dtml-if omit_input>\n
AND stock.quantity < 0\n
AND (stock.node_uid <> stock.mirror_node_uid\n
......
2006-09-04 jerome
* remove omit_simulation parameter in all inventory API ZSQLMethods.
2006-08-25 Stefan
* Update naming convention script.
......
55
\ No newline at end of file
56
\ No newline at end of file
......@@ -271,6 +271,15 @@ class TestInventory(InventoryAPITestCase):
get_transaction().commit(); self.tic() # (after reindexing of course)
self.assertEquals(100, getInventory(section_uid=self.section.getUid()))
def test_OmitSimulation(self, quiet=0, run=RUN_ALL_TESTS):
"""Test omit_simulation argument to getInventory.
"""
getInventory = self.getSimulationTool().getInventory
self._makeSimulationMovement(quantity=100)
self._makeMovement(quantity=100)
self.assertEquals(100, getInventory(section_uid=self.section.getUid(),
omit_simulation=1))
def test_SectionCategory(self, quiet=0, run=RUN_ALL_TESTS):
"""Tests inventory on section category. """
getInventory = self.getSimulationTool().getInventory
......@@ -819,6 +828,27 @@ class TestMovementHistoryList(InventoryAPITestCase):
section_uid=self.section.getUid())
self.assertEquals(len(movement_history_list), 2)
def test_SimulationMovement(self, quiet=0, run=RUN_ALL_TESTS):
"""Test simulation movement are listed in getMovementHistoryList
"""
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
self._makeSimulationMovement(quantity=100)
self._makeMovement(quantity=100)
movement_history_list = getMovementHistoryList(
section_uid=self.section.getUid())
self.assertEquals(2, len(movement_history_list))
def test_OmitSimulation(self, quiet=0, run=RUN_ALL_TESTS):
"""Test omit_simulation argument to getMovementHistoryList.
"""
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
self._makeSimulationMovement(quantity=100)
self._makeMovement(quantity=100)
movement_history_list = getMovementHistoryList(
section_uid=self.section.getUid(),
omit_simulation=1)
self.assertEquals(1, len(movement_history_list))
self.assertEquals(100, movement_history_list[0].quantity)
class TestInventoryStat(InventoryAPITestCase):
"""Tests Inventory Stat methods.
......
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