Commit b2b2ec5a authored by Nicolas Dumazet's avatar Nicolas Dumazet

improve Inventory API to retrieve transformed inventory lists.

Work in progress: transformations are not yet properly indexed,
tests are not written. this commit is just to share in advance a common API


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33211 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fe70a1cf
...@@ -191,7 +191,9 @@ class InventoryListBrain(ZSQLBrain): ...@@ -191,7 +191,9 @@ class InventoryListBrain(ZSQLBrain):
# Add parameters to query_kw # Add parameters to query_kw
query_kw_update = {} query_kw_update = {}
if cname_id in ('getCurrentInventory', ): if cname_id in ('transformed_resource_title', ):
return '%s/view' % resource.absolute_url()
elif cname_id in ('getCurrentInventory', ):
query_kw_update = { query_kw_update = {
'simulation_state': 'simulation_state':
list(self.getPortalCurrentInventoryStateList() + \ list(self.getPortalCurrentInventoryStateList() + \
......
...@@ -429,6 +429,7 @@ class SimulationTool(BaseTool): ...@@ -429,6 +429,7 @@ class SimulationTool(BaseTool):
# Group-by expression # Group-by expression
group_by = new_kw.pop('group_by', []) group_by = new_kw.pop('group_by', [])
column_group_by = new_kw.pop('column_group_by', []) column_group_by = new_kw.pop('column_group_by', [])
if column_group_by: if column_group_by:
group_by.extend(['%s.%s' % (table, x) for x in column_group_by]) group_by.extend(['%s.%s' % (table, x) for x in column_group_by])
related_key_group_by = new_kw.pop('related_key_group_by', []) related_key_group_by = new_kw.pop('related_key_group_by', [])
...@@ -506,7 +507,7 @@ class SimulationTool(BaseTool): ...@@ -506,7 +507,7 @@ class SimulationTool(BaseTool):
# instances # instances
resource=None, node=None, payment=None, resource=None, node=None, payment=None,
section=None, mirror_section=None, item=None, section=None, mirror_section=None, item=None,
function=None, project=None, function=None, project=None, transformed_resource=None,
# used for tracking # used for tracking
input=0, output=0, input=0, output=0,
# categories # categories
...@@ -529,6 +530,7 @@ class SimulationTool(BaseTool): ...@@ -529,6 +530,7 @@ class SimulationTool(BaseTool):
# variations # variations
variation_text=None, sub_variation_text=None, variation_text=None, sub_variation_text=None,
variation_category=None, variation_category=None,
transformed_variation_text=None,
# uids # uids
resource_uid=None, node_uid=None, section_uid=None, payment_uid=None, resource_uid=None, node_uid=None, section_uid=None, payment_uid=None,
mirror_node_uid=None, mirror_section_uid=None, function_uid=None, mirror_node_uid=None, mirror_section_uid=None, function_uid=None,
...@@ -622,6 +624,9 @@ class SimulationTool(BaseTool): ...@@ -622,6 +624,9 @@ class SimulationTool(BaseTool):
column_value_dict.setUIDList('payment_uid', payment) column_value_dict.setUIDList('payment_uid', payment)
column_value_dict.setUIDList('project_uid', project) column_value_dict.setUIDList('project_uid', project)
column_value_dict.setUIDList('function_uid', function) column_value_dict.setUIDList('function_uid', function)
sql_kw['transformed_uid'] = self._generatePropertyUidList(transformed_resource)
if column_value_dict.setUIDList('section_uid', section): if column_value_dict.setUIDList('section_uid', section):
sql_kw['section_filtered'] = 1 sql_kw['section_filtered'] = 1
column_value_dict.setUIDList('mirror_section_uid', mirror_section) column_value_dict.setUIDList('mirror_section_uid', mirror_section)
...@@ -874,6 +879,17 @@ class SimulationTool(BaseTool): ...@@ -874,6 +879,17 @@ class SimulationTool(BaseTool):
quantity_unit - display results using this specific quantity unit quantity_unit - display results using this specific quantity unit
transformed_resource - one, or several resources. list resources that can
be produced using those resources as input in a
transformation.
relative_resource_url for each returned line will
point to the transformed resource, while the stock
will be the stock of the produced resource,
expressed in number of transformed resources.
transformed_variation_text - to be used with transformed_resource, to
to refine the transformation selection only
to those using variated resources as input.
**kw - if we want extended selection with more keywords (but **kw - if we want extended selection with more keywords (but
bad performance) check what we can do with bad performance) check what we can do with
buildSQLQuery buildSQLQuery
......
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