Commit 68d2be90 authored by Jérome Perrin's avatar Jérome Perrin

get portal methods from portal, and remove unnecessary casts

parent 45f7c33b
...@@ -1681,10 +1681,11 @@ class SimulationTool(BaseTool): ...@@ -1681,10 +1681,11 @@ class SimulationTool(BaseTool):
""" """
Returns list of current inventory grouped by section or site Returns list of current inventory grouped by section or site
""" """
kw['simulation_state'] = self.getPortalCurrentInventoryStateList() + \ portal = self.getPortalObject()
self.getPortalTransitInventoryStateList() kw['simulation_state'] = portal.getPortalCurrentInventoryStateList() + \
portal.getPortalTransitInventoryStateList()
if transit_simulation_state is None: if transit_simulation_state is None:
transit_simulation_state = self.getPortalTransitInventoryStateList() transit_simulation_state = portal.getPortalTransitInventoryStateList()
return self.getInventoryList( return self.getInventoryList(
omit_transit=omit_transit, omit_transit=omit_transit,
...@@ -1697,11 +1698,12 @@ class SimulationTool(BaseTool): ...@@ -1697,11 +1698,12 @@ class SimulationTool(BaseTool):
""" """
Returns list of current inventory grouped by section or site Returns list of current inventory grouped by section or site
""" """
portal = self.getPortalObject()
if transit_simulation_state is None: if transit_simulation_state is None:
transit_simulation_state = self.getPortalTransitInventoryStateList() transit_simulation_state = portal.getPortalTransitInventoryStateList()
kw['simulation_state'] = self.getPortalCurrentInventoryStateList() + \ kw['simulation_state'] = portal.getPortalCurrentInventoryStateList() + \
self.getPortalTransitInventoryStateList() portal.getPortalTransitInventoryStateList()
reserved_kw = {'simulation_state': self.getPortalReservedInventoryStateList(), reserved_kw = {'simulation_state': portal.getPortalReservedInventoryStateList(),
'transit_simulation_state': transit_simulation_state, 'transit_simulation_state': transit_simulation_state,
'omit_input': 1} 'omit_input': 1}
return self.getInventoryList(reserved_kw=reserved_kw, omit_transit=omit_transit, return self.getInventoryList(reserved_kw=reserved_kw, omit_transit=omit_transit,
...@@ -1713,11 +1715,11 @@ class SimulationTool(BaseTool): ...@@ -1713,11 +1715,11 @@ class SimulationTool(BaseTool):
""" """
Returns list of future inventory grouped by section or site Returns list of future inventory grouped by section or site
""" """
kw['simulation_state'] = tuple( portal = self.getPortalObject()
list(self.getPortalFutureInventoryStateList()) + \ kw['simulation_state'] = portal.getPortalFutureInventoryStateList() + \
list(self.getPortalTransitInventoryStateList()) + \ portal.getPortalTransitInventoryStateList() + \
list(self.getPortalReservedInventoryStateList()) + \ portal.getPortalReservedInventoryStateList() + \
list(self.getPortalCurrentInventoryStateList())) portal.getPortalCurrentInventoryStateList()
return self.getInventoryList(**kw) return self.getInventoryList(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -1781,7 +1783,8 @@ class SimulationTool(BaseTool): ...@@ -1781,7 +1783,8 @@ class SimulationTool(BaseTool):
""" """
Returns list of current inventory grouped by section or site Returns list of current inventory grouped by section or site
""" """
kw['simulation_state'] = self.getPortalCurrentInventoryStateList() kw['simulation_state'] = self.getPortalObject()\
.getPortalCurrentInventoryStateList()
return self.getInventoryChart(**kw) return self.getInventoryChart(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -1790,10 +1793,10 @@ class SimulationTool(BaseTool): ...@@ -1790,10 +1793,10 @@ class SimulationTool(BaseTool):
""" """
Returns list of future inventory grouped by section or site Returns list of future inventory grouped by section or site
""" """
kw['simulation_state'] = tuple( portal = self.getPortalObject()
list(self.getPortalFutureInventoryStateList()) + \ kw['simulation_state'] = portal.getPortalFutureInventoryStateList() + \
list(self.getPortalReservedInventoryStateList()) + \ portal.getPortalReservedInventoryStateList() + \
list(self.getPortalCurrentInventoryStateList())) portal.getPortalCurrentInventoryStateList()
return self.getInventoryChart(**kw) return self.getInventoryChart(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -1873,9 +1876,9 @@ class SimulationTool(BaseTool): ...@@ -1873,9 +1876,9 @@ class SimulationTool(BaseTool):
Returns list of available inventory grouped by section or site Returns list of available inventory grouped by section or site
(current inventory - deliverable) (current inventory - deliverable)
""" """
kw['simulation_state'] = tuple( portal = self.getPortalObject()
list(self.getPortalReservedInventoryStateList()) + \ kw['simulation_state'] = portal.getPortalReservedInventoryStateList() + \
list(self.getPortalCurrentInventoryStateList())) portal.getPortalCurrentInventoryStateList()
return self.getInventoryAssetPrice(**kw) return self.getInventoryAssetPrice(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -1884,10 +1887,10 @@ class SimulationTool(BaseTool): ...@@ -1884,10 +1887,10 @@ class SimulationTool(BaseTool):
""" """
Returns list of future inventory grouped by section or site Returns list of future inventory grouped by section or site
""" """
kw['simulation_state'] = tuple( portal = self.getPortalObject()
list(self.getPortalFutureInventoryStateList()) + \ kw['simulation_state'] = portal.getPortalFutureInventoryStateList() + \
list(self.getPortalReservedInventoryStateList()) + \ portal.getPortalReservedInventoryStateList() + \
list(self.getPortalCurrentInventoryStateList())) portal.getPortalCurrentInventoryStateList()
return self.getInventoryAssetPrice(**kw) return self.getInventoryAssetPrice(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -2138,7 +2141,8 @@ class SimulationTool(BaseTool): ...@@ -2138,7 +2141,8 @@ class SimulationTool(BaseTool):
""" """
Returns list of current inventory grouped by section or site Returns list of current inventory grouped by section or site
""" """
kw['item.simulation_state'] = self.getPortalCurrentInventoryStateList() kw['item.simulation_state'] = self.getPortalObject()\
.getPortalCurrentInventoryStateList()
return self.getTrackingList(**kw) return self.getTrackingList(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentTrackingHistoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentTrackingHistoryList')
...@@ -2146,7 +2150,8 @@ class SimulationTool(BaseTool): ...@@ -2146,7 +2150,8 @@ class SimulationTool(BaseTool):
""" """
Returns list of current inventory grouped by section or site Returns list of current inventory grouped by section or site
""" """
kw['item.simulation_state'] = self.getPortalCurrentInventoryStateList() kw['item.simulation_state'] = self.getPortalObject()\
.getPortalCurrentInventoryStateList()
return self.getTrackingHistoryList(**kw) return self.getTrackingHistoryList(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getTrackingHistoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getTrackingHistoryList')
...@@ -2162,11 +2167,11 @@ class SimulationTool(BaseTool): ...@@ -2162,11 +2167,11 @@ class SimulationTool(BaseTool):
""" """
Returns list of future inventory grouped by section or site Returns list of future inventory grouped by section or site
""" """
kw['item.simulation_state'] = tuple( portal = self.getPortalObject()
list(self.getPortalFutureInventoryStateList()) + \ kw['item.simulation_state'] = portal.getPortalFutureInventoryStateList() + \
list(self.getPortalTransitInventoryStateList()) + \ portal.getPortalTransitInventoryStateList() + \
list(self.getPortalReservedInventoryStateList()) + \ portal.getPortalReservedInventoryStateList() + \
list(self.getPortalCurrentInventoryStateList())) portal.getPortalCurrentInventoryStateList()
return self.getTrackingList(**kw) return self.getTrackingList(**kw)
####################################################### #######################################################
...@@ -2858,15 +2863,16 @@ class SimulationTool(BaseTool): ...@@ -2858,15 +2863,16 @@ class SimulationTool(BaseTool):
if (from_date is None) or (to_date is None): if (from_date is None) or (to_date is None):
raise NotImplementedError, \ raise NotImplementedError, \
"getAvailableTime does not managed yet None values" "getAvailableTime does not managed yet None values"
portal = self.getPortalObject()
# Calculate portal_type # Calculate portal_type
if portal_type == []: if portal_type == []:
portal_type = self.getPortalCalendarPeriodTypeList() portal_type = portal.getPortalCalendarPeriodTypeList()
simulation_state = self.getPortalCurrentInventoryStateList() + \ simulation_state = portal.getPortalCurrentInventoryStateList() + \
self.getPortalTransitInventoryStateList() + \ portal.getPortalTransitInventoryStateList() + \
self.getPortalReservedInventoryStateList() portal.getPortalReservedInventoryStateList()
sql_result = self.Person_zGetAvailableTime( sql_result = portal.Person_zGetAvailableTime(
from_date=from_date, from_date=from_date,
to_date=to_date, to_date=to_date,
portal_type=portal_type, portal_type=portal_type,
...@@ -2910,9 +2916,10 @@ class SimulationTool(BaseTool): ...@@ -2910,9 +2916,10 @@ class SimulationTool(BaseTool):
hour, day, hour, day,
month, year - duration of each time period (cumulative) month, year - duration of each time period (cumulative)
""" """
portal = self.getPortalObject()
# Calculate portal_type # Calculate portal_type
if portal_type == []: if portal_type == []:
portal_type = self.getPortalCalendarPeriodTypeList() portal_type = portal.getPortalCalendarPeriodTypeList()
sequence = Sequence(from_date, to_date, **kw) sequence = Sequence(from_date, to_date, **kw)
for sequence_item in sequence: for sequence_item in sequence:
......
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