Commit b575dfc5 authored by Jérome Perrin's avatar Jérome Perrin

support group_by= as string, and test some other cases of group_by=


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36269 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 51daa2f8
......@@ -442,6 +442,9 @@ class SimulationTool(BaseTool):
# group by involving a related key (eg. group_by=['product_line_uid'])
related_key_dict_passthrough_group_by = new_kw.get(
'related_key_dict_passthrough', dict()).pop('group_by', [])
if isinstance(related_key_dict_passthrough_group_by, basestring):
related_key_dict_passthrough_group_by = (
related_key_dict_passthrough_group_by,)
group_by.extend(related_key_dict_passthrough_group_by)
if group_by:
......
......@@ -896,8 +896,27 @@ class TestInventoryList(InventoryAPITestCase):
if r.getObject().getUse() == 'use1'][0].inventory, 5)
self.assertEquals([r for r in inventory_list
if r.getObject().getUse() == 'use2'][0].inventory, 11)
# group_by can also be passed as string
inventory_list = getInventoryList(node_uid=(self.node.getUid(),
self.other_node.getUid()),
group_by='strict_use_uid', )
self.assertEquals(2, len(inventory_list))
self.assertEquals([r for r in inventory_list
if r.getObject().getUse() == 'use1'][0].inventory, 5)
self.assertEquals([r for r in inventory_list
if r.getObject().getUse() == 'use2'][0].inventory, 11)
# the name of a column can also be used, from stock or other tables
inventory_list = getInventoryList(node_uid=(self.node.getUid(),
self.other_node.getUid()),
group_by='node_uid', )
self.assertEquals(2, len(inventory_list))
inventory_list = getInventoryList(node_uid=(self.node.getUid(),
self.other_node.getUid()),
group_by='title', )
self.assertEquals(4, len(inventory_list))
# mixed with group_by_* arguments
# group_by= can be mixed with group_by_* arguments
inventory_list = getInventoryList(node_uid=(self.node.getUid(),
self.other_node.getUid()),
group_by_node=True,
......
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