Commit 85084db0 authored by Vincent Pelletier's avatar Vincent Pelletier

Update group-by heuristic method:

  - it's its job to handle group-by-resource-by-default behaviour when another group-by is provided
  - move task of updating dictionnary from this method to caller, to make it easier to understand when reading caller


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16062 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8c1148ef
...@@ -806,20 +806,34 @@ class SimulationTool(BaseTool): ...@@ -806,20 +806,34 @@ class SimulationTool(BaseTool):
""" """
return self.getInventory(simulation_period='Future', **kw) return self.getInventory(simulation_period='Future', **kw)
def _getDefaultGroupByParameters(self, ignore_group_by=0, **kw): def _getDefaultGroupByParameters(self, ignore_group_by=0,
group_by_node=0, group_by_mirror_node=0,
group_by_section=0, group_by_mirror_section=0,
group_by_payment=0,
group_by_variation=0, group_by_sub_variation=0,
group_by_movement=0,
group_by_resource=1,
**ignored):
""" """
Set defaults group_by parameters Set defaults group_by parameters
If ignore_group_by is true, this function returns an empty dict.
If any group-by is provided, automatically group by resource aswell
unless group_by_resource is explicitely set to false.
If no group by is provided, group by movement, node and resource.
""" """
if not (ignore_group_by \ new_group_by_dict = {}
or kw.get('group_by_node', 0) or kw.get('group_by_mirror_node', 0) \ if not ignore_group_by:
or kw.get('group_by_section', 0) or kw.get('group_by_mirror_section', 0) \ if group_by_node or group_by_mirror_node or group_by_section or \
or kw.get('group_by_payment', 0) or kw.get('group_by_sub_variation', 0) \ group_by_mirror_section or group_by_payment or \
or kw.get('group_by_variation', 0) or kw.get('group_by_movement', 0) \ group_by_sub_variation or group_by_variation or group_by_movement:
or kw.get('group_by_resource', 0)): new_group_by_dict['group_by_resource'] = group_by_resource
kw['group_by_movement'] = 1 else:
kw['group_by_node'] = 1 new_group_by_dict['group_by_movement'] = 1
kw['group_by_resource'] = 1 new_group_by_dict['group_by_node'] = 1
return kw new_group_by_dict['group_by_resource'] = 1
return new_group_by_dict
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getInventoryList') 'getInventoryList')
...@@ -838,7 +852,7 @@ class SimulationTool(BaseTool): ...@@ -838,7 +852,7 @@ class SimulationTool(BaseTool):
average, cost, etc.) average, cost, etc.)
""" """
# If no group at all, give a default sort group by # If no group at all, give a default sort group by
kw = self._getDefaultGroupByParameters(**kw) kw.update(self._getDefaultGroupByParameters(**kw))
sql_kw = self._generateSQLKeywordDict(**kw) sql_kw = self._generateSQLKeywordDict(**kw)
return self.Resource_zGetInventoryList( return self.Resource_zGetInventoryList(
src__=src__, ignore_variation=ignore_variation, src__=src__, ignore_variation=ignore_variation,
......
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