Commit 7814c521 authored by Jérome Perrin's avatar Jérome Perrin

Add more columns in default group by for getMovementHistoryList, this way when

we have a movement with same source and same destination, it shows two distinct
lines in getMovementHistoryList
Update the TODOs for testInventoryAPI



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17088 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cb8c4276
......@@ -844,7 +844,10 @@ class SimulationTool(BaseTool):
If no group by is provided, use the default group by: movement, node and
resource, unless movement_list_mode is true, in that case, group by
movement, node, resource and date (this is historically the default in
getMovementHistoryList).
getMovementHistoryList), section, mirror_section and payment (this is to
make sure two lines will appear when we are, for instance both source and
destination, implementation might not be optimal, because it uses lots of
group by statements in SQL).
"""
new_group_by_dict = {}
if not ignore_group_by:
......@@ -861,6 +864,10 @@ class SimulationTool(BaseTool):
new_group_by_dict['group_by_resource'] = 1
if movement_list_mode:
new_group_by_dict['group_by_date'] = 1
new_group_by_dict['group_by_mirror_node'] = 1
new_group_by_dict['group_by_section'] = 1
new_group_by_dict['group_by_mirror_section'] = 1
new_group_by_dict['group_by_payment'] = 1
return new_group_by_dict
security.declareProtected(Permissions.AccessContentsInformation,
......
......@@ -29,7 +29,7 @@
"""Unit Tests for Inventory API.
TODO: test variation
test selection_domain, selection_report
"""
import os
......@@ -1275,6 +1275,17 @@ class TestMovementHistoryList(InventoryAPITestCase):
node_uid=self.node.getUid(),)
self.assertEquals(2, len(mvt_history_list))
self.assertEquals(0, sum([r.total_quantity for r in mvt_history_list]))
def testSameNodeSameDates(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
mvt = self._makeMovement( quantity=2,
start_date=DateTime(),
source_value=self.node,
destination_value=self.node )
mvt_history_list = getMovementHistoryList(
node_uid=self.node.getUid(),)
self.assertEquals(2, len(mvt_history_list))
self.assertEquals(0, sum([r.total_quantity for r in mvt_history_list]))
def testPrecision(self):
# getMovementHistoryList supports a precision= argument to specify the
......
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