From 7794399a5f8179f1e218691378849d974cf40cb7 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Thu, 8 Mar 2007 15:23:34 +0000 Subject: [PATCH] getAvailableTime can filter by resource. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13288 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Tool/SimulationTool.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/product/ERP5/Tool/SimulationTool.py b/product/ERP5/Tool/SimulationTool.py index 6e4b244403..421a67f109 100644 --- a/product/ERP5/Tool/SimulationTool.py +++ b/product/ERP5/Tool/SimulationTool.py @@ -1760,7 +1760,8 @@ class SimulationTool(BaseTool): security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableTime') def getAvailableTime(self, from_date=None, to_date=None, - portal_type=[], node=[], **kw): + portal_type=[], node=[], + resource=[], src__=0, **kw): """ Calculate available time for a node Returns an inventory of a single or multiple resources on a single @@ -1773,6 +1774,9 @@ class SimulationTool(BaseTool): node - only take rows in stock table which node_uid is equivalent to node + resource - only take rows in stock table which resource_uid is + equivalent to resource + portal_type - only take rows in stock table which portal_type is in portal_type parameter """ @@ -1789,8 +1793,11 @@ class SimulationTool(BaseTool): to_date=to_date, portal_type=portal_type, node=node, - **kw)[0].total_quantity - if (result is None) or (result < 0): + resource=resource, + src__=src__, **kw)[0].total_quantity + if src__: + return result_list + elif (result is None) or (result < 0): result = 0 return result @@ -1798,6 +1805,7 @@ class SimulationTool(BaseTool): 'getAvailableTimeSequence') def getAvailableTimeSequence(self, from_date, to_date, portal_type=[], node=[], + resource=[], src__=0, **kw): """ @@ -1826,7 +1834,11 @@ class SimulationTool(BaseTool): period_list=Sequence(from_date, to_date, **kw), portal_type=portal_type, node=node, + resource=resource, src__=src__) + for x in result_list: + if x.total_quantity < 0: + x.total_quantity = 0 return result_list from Products.ERP5Type.DateUtils import addToDate -- 2.30.9