From b2b2ec5ab394bc4ddec44d647a78fa49731114b1 Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet <nicolas.dumazet@nexedi.com> Date: Tue, 2 Mar 2010 05:55:52 +0000 Subject: [PATCH] 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 --- product/ERP5/Extensions/InventoryBrain.py | 4 +++- product/ERP5/Tool/SimulationTool.py | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/product/ERP5/Extensions/InventoryBrain.py b/product/ERP5/Extensions/InventoryBrain.py index 8c03bf222e..d13c065390 100644 --- a/product/ERP5/Extensions/InventoryBrain.py +++ b/product/ERP5/Extensions/InventoryBrain.py @@ -191,7 +191,9 @@ class InventoryListBrain(ZSQLBrain): # Add parameters to query_kw 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 = { 'simulation_state': list(self.getPortalCurrentInventoryStateList() + \ diff --git a/product/ERP5/Tool/SimulationTool.py b/product/ERP5/Tool/SimulationTool.py index 06c0ece345..9f42a2f7be 100644 --- a/product/ERP5/Tool/SimulationTool.py +++ b/product/ERP5/Tool/SimulationTool.py @@ -429,6 +429,7 @@ class SimulationTool(BaseTool): # Group-by expression group_by = new_kw.pop('group_by', []) column_group_by = new_kw.pop('column_group_by', []) + if 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', []) @@ -506,7 +507,7 @@ class SimulationTool(BaseTool): # instances resource=None, node=None, payment=None, section=None, mirror_section=None, item=None, - function=None, project=None, + function=None, project=None, transformed_resource=None, # used for tracking input=0, output=0, # categories @@ -529,6 +530,7 @@ class SimulationTool(BaseTool): # variations variation_text=None, sub_variation_text=None, variation_category=None, + transformed_variation_text=None, # uids resource_uid=None, node_uid=None, section_uid=None, payment_uid=None, mirror_node_uid=None, mirror_section_uid=None, function_uid=None, @@ -622,6 +624,9 @@ class SimulationTool(BaseTool): column_value_dict.setUIDList('payment_uid', payment) column_value_dict.setUIDList('project_uid', project) column_value_dict.setUIDList('function_uid', function) + + sql_kw['transformed_uid'] = self._generatePropertyUidList(transformed_resource) + if column_value_dict.setUIDList('section_uid', section): sql_kw['section_filtered'] = 1 column_value_dict.setUIDList('mirror_section_uid', mirror_section) @@ -874,6 +879,17 @@ class SimulationTool(BaseTool): 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 bad performance) check what we can do with buildSQLQuery -- 2.30.9