Commit 7794399a authored by Romain Courteaud's avatar Romain Courteaud

getAvailableTime can filter by resource.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13288 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 11af6fc3
...@@ -1760,7 +1760,8 @@ class SimulationTool(BaseTool): ...@@ -1760,7 +1760,8 @@ class SimulationTool(BaseTool):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getAvailableTime') 'getAvailableTime')
def getAvailableTime(self, from_date=None, to_date=None, 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 Calculate available time for a node
Returns an inventory of a single or multiple resources on a single Returns an inventory of a single or multiple resources on a single
...@@ -1773,6 +1774,9 @@ class SimulationTool(BaseTool): ...@@ -1773,6 +1774,9 @@ class SimulationTool(BaseTool):
node - only take rows in stock table which node_uid is node - only take rows in stock table which node_uid is
equivalent to node 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 portal_type - only take rows in stock table which portal_type
is in portal_type parameter is in portal_type parameter
""" """
...@@ -1789,8 +1793,11 @@ class SimulationTool(BaseTool): ...@@ -1789,8 +1793,11 @@ class SimulationTool(BaseTool):
to_date=to_date, to_date=to_date,
portal_type=portal_type, portal_type=portal_type,
node=node, node=node,
**kw)[0].total_quantity resource=resource,
if (result is None) or (result < 0): src__=src__, **kw)[0].total_quantity
if src__:
return result_list
elif (result is None) or (result < 0):
result = 0 result = 0
return result return result
...@@ -1798,6 +1805,7 @@ class SimulationTool(BaseTool): ...@@ -1798,6 +1805,7 @@ class SimulationTool(BaseTool):
'getAvailableTimeSequence') 'getAvailableTimeSequence')
def getAvailableTimeSequence(self, from_date, to_date, def getAvailableTimeSequence(self, from_date, to_date,
portal_type=[], node=[], portal_type=[], node=[],
resource=[],
src__=0, src__=0,
**kw): **kw):
""" """
...@@ -1826,7 +1834,11 @@ class SimulationTool(BaseTool): ...@@ -1826,7 +1834,11 @@ class SimulationTool(BaseTool):
period_list=Sequence(from_date, to_date, **kw), period_list=Sequence(from_date, to_date, **kw),
portal_type=portal_type, portal_type=portal_type,
node=node, node=node,
resource=resource,
src__=src__) src__=src__)
for x in result_list:
if x.total_quantity < 0:
x.total_quantity = 0
return result_list return result_list
from Products.ERP5Type.DateUtils import addToDate from Products.ERP5Type.DateUtils import addToDate
......
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