Commit c4e1897d authored by Alexandre Boeglin's avatar Alexandre Boeglin

getInventory now belongs to SimulationTool.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2721 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8ce7c5b1
...@@ -884,318 +884,142 @@ class Delivery(XMLObject): ...@@ -884,318 +884,142 @@ class Delivery(XMLObject):
return resource_dict.keys() return resource_dict.keys()
security.declareProtected(Permissions.AccessContentsInformation, 'getInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getInventory')
def getInventory(self, at_date = None, section = None, node = None, payment = None, def getInventory(self, **kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None, """
ignore_variation=0, **kw): Returns inventory
if section_category is None: """
section_category = self.getPortalDefaultSectionCategory() kw['resource'] = self._getMovementResourceList()
if type(simulation_state) is type('a'): return self.portal_simulation.getInventory(**kw)
simulation_state = [simulation_state]
resource_dict = {}
for m in self.contentValues(filter={'portal_type': self.getPortalMovementTypeList()}):
resource_dict[m.getResource()] = 1
result = self.Resource_zGetInventory( resource = self._getMovementResourceList(),
to_date=at_date,
section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category,
simulation_state=simulation_state)
if len(result) > 0:
return result[0].inventory
return 0.0
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventory')
def getFutureInventory(self, section = None, node = None, payment = None,
node_category=None, section_category=None, payment_category = None, simulation_state=None,
ignore_variation=0, **kw):
"""
Returns inventory at infinite
"""
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventory(at_date=None, section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category,
simulation_state=list(self.getPortalFutureInventoryStateList())+\
list(self.getPortalReservedInventoryStateList())+\
list(self.getPortalCurrentInventoryStateList()), **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory')
def getCurrentInventory(self, section = None, node = None, payment = None, def getCurrentInventory(**kw):
node_category=None, section_category=None, payment_category = None, ignore_variation=0, **kw): """
""" Returns current inventory
Returns current inventory """
""" kw['category'] = self._getMovementResourceList()
if section_category is None: return self.portal_simulation.getCurrentInventory(**kw)
section_category = self.getPortalDefaultSectionCategory()
return self.getInventory(section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category,
simulation_state=self.getPortalCurrentInventoryStateList(), **kw)
#return self.getInventory(section=section, node=node, payment=payment
# node_category=node_category, section_category=section_category, payment_category=payment_category,
# simulation_state='delivered', **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventory')
def getAvailableInventory(self, section = None, node = None, payment = None, def getAvailableInventory(**kw):
node_category=None, section_category=None, payment_category = None, """
ignore_variation=0, **kw): Returns available inventory
(current inventory - deliverable)
"""
kw['category'] = self._getMovementResourceList()
return self.portal_simulation.getAvailableInventory(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventory')
def getFutureInventory(**kw):
""" """
Returns available inventory, ie. current inventory - deliverable Returns inventory at infinite
""" """
if section_category is None: kw['category'] = self._getMovementResourceList()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getFutureInventory(**kw)
return self.getInventory(at_date=DateTime(), section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryList')
def getInventoryList(self, at_date = None, section = None, node = None, payment = None, def getInventoryList(self, **kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None,
ignore_variation=0, **kw):
""" """
Returns list of inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None: kw['category'] = self._getMovementResourceList()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getInventoryList(**kw)
if type(simulation_state) is type('a'):
simulation_state = [simulation_state]
resource_dict = {}
for m in self.contentValues(filter={'portal_type': self.getPortalMovementTypeList()}):
resource_dict[m.getResource()] = 1
result = self.Resource_zGetInventoryList(resource = resource_dict.keys(),
to_date=at_date,
section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category,
simulation_state=simulation_state, **kw)
return result security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryList')
def getCurrentInventoryList(**kw):
"""
Returns list of inventory grouped by section or site
"""
kw['category'] = self._getMovementResourceList()
return self.portal_simulation.getCurrentInventoryList(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryList')
def getFutureInventoryList(self, section = None, node = None, payment = None, def getFutureInventoryList(**kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None, """
ignore_variation=0, **kw): Returns list of inventory grouped by section or site
""" """
Returns list of future inventory grouped by section or site kw['category'] = self._getMovementResourceList()
""" return self.portal_simulation.getFutureInventoryList(**kw)
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryList(at_date=None, section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category,
simulation_state=list(self.getPortalFutureInventoryStateList())+\
list(self.getPortalReservedInventoryStateList())+\
list(self.getPortalCurrentInventoryStateList()), **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryList')
def getCurrentInventoryList(self, section = None, node = None, payment = None,
node_category=None, section_category=None, payment_category = None,
ignore_variation=0, **kw):
"""
Returns list of current inventory grouped by section or site
"""
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryList(simulation_state=self.getPortalCurrentInventoryStateList(), section=section,
node=node, payment=payment,
node_category=node_category, section_category=section_category,
payment_category=payment_category, **kw)
#return self.getInventoryList(at_date=DateTime(), section=section, node=node, payment=payment
# node_category=node_category, section_category=section_category,
# payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryStat')
def getInventoryStat(self, at_date = None, section = None, node = None, payment = None, def getInventoryStat(self, **kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None,
ignore_variation=0, **kw):
""" """
Returns statistics of inventory list grouped by section or site Returns statistics of inventory grouped by section or site
""" """
if section_category is None: kw['category'] = self._getMovementResourceList()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getInventoryStat(**kw)
resource_dict = {}
if type(simulation_state) is type('a'):
simulation_state = [simulation_state]
for m in self.contentValues(filter={'portal_type': self.getPortalMovementTypeList()}):
resource_dict[m.getResource()] = 1
result = self.Resource_zGetInventory(resource = resource_dict.keys(),
to_date=at_date,
section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category, **kw)
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryStat')
def getFutureInventoryStat(self, section = None, node = None, payment = None, def getCurrentInventoryStat(**kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None,
ignore_variation=0, **kw):
""" """
Returns statistics of future inventory list grouped by section or site Returns statistics of inventory grouped by section or site
""" """
if section_category is None: kw['category'] = self._getMovementResourceList()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getCurrentInventoryStat(**kw)
return self.getInventoryStat(at_date=None, section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category,
payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryStat')
def getCurrentInventoryStat(self, section = None, node = None, payment = None, def getFutureInventoryStat(**kw):
node_category=None, section_category=None, payment_category = None,
ignore_variation=0, **kw):
""" """
Returns statistics of current inventory list grouped by section or site Returns statistics of inventory grouped by section or site
""" """
if section_category is None: kw['category'] = self._getMovementResourceList()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getFutureInventoryStat(**kw)
return self.getInventoryStat(simulation_state='delivered', section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category,
payment_category=payment_category, **kw)
#return self.getInventoryStat(at_date=DateTime(), section=section, node=node, payment=payment
# node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryChart')
def getInventoryChart(self, at_date = None, section = None, node = None, payment = None, def getInventoryChart(self, **kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None, """
ignore_variation=0, **kw): Returns list of inventory grouped by section or site
""" """
Returns list of inventory grouped by section or site kw['category'] = self._getMovementResourceList()
""" return self.portal_simulation.getInventoryChart(**kw)
if section_category is None:
section_category = self.getPortalDefaultSectionCategory() security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryChart')
if type(simulation_state) is type('a'): def getCurrentInventoryChart(**kw):
simulation_state = [simulation_state] """
result = self.getInventoryList(at_date=at_date, section=section, node=node, payment=payment, Returns list of inventory grouped by section or site
node_category=node_category, """
section_category=section_category, kw['category'] = self._getMovementResourceList()
payment_category=payment_category, return self.portal_simulation.getCurrentInventoryChart(**kw)
simulation_state=simulation_state, ignore_variation=ignore_variation, **kw)
return map(lambda r: (r.node_title, r.inventory), result)
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryChart')
def getFutureInventoryChart(self, section = None, node = None, payment = None, def getFutureInventoryChart(**kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None,
ignore_variation=0, **kw):
""" """
Returns list of future inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None: kw['category'] = self._getMovementResourceList()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getFutureInventoryChart(**kw)
return self.getInventoryChart(at_date=None, section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category,
payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryList')
def getCurrentInventoryChart(self, section = None, node = None, payment = None, def getInventoryHistoryList(**kw):
node_category=None, section_category=None, payment_category = None,
ignore_variation=0, **kw):
""" """
Returns list of current inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None: kw['category'] = self._getMovementResourceList()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getInventoryHistoryList(**kw)
return self.getInventoryChart(simulation_state=self.getPortalCurrentInventoryStateList(), section=section,
node=node, payment=payment,
node_category=node_category, section_category=section_category,
payment_category=payment_category, **kw)
# return self.getInventoryChart(at_date=DateTime(), section=section, node=node, payment=payment,
# node_category=node_category, section_category=section_category,
# payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryChart')
def getInventoryHistoryChart(**kw):
"""
Returns list of inventory grouped by section or site
"""
kw['category'] = self._getMovementResourceList()
return self.portal_simulation.getInventoryHistoryChart(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryList')
def getMovementHistoryList(self, from_date = None, to_date=None, section = None, node = None, payment = None, def getMovementHistoryList(**kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None, """
ignore_variation=0, **kw): Returns list of inventory grouped by section or site
""" """
Returns list of inventory grouped by section or site kw['category'] = self._getMovementResourceList()
""" return self.portal_simulation.getMovementHistoryList(**kw)
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_zGetMovementHistoryList(resource = self._getMovementResourceList(),
from_date=from_date,
to_date=to_date,
section=section,
node=node,
payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category, **kw)
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryStat')
def getMovementHistoryStat(self, from_date = None, to_date=None, section = None, node = None, payment = None, def getMovementHistoryStat(**kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None, """
ignore_variation=0, **kw): Returns list of inventory grouped by section or site
""" """
Returns list of inventory grouped by section or site kw['category'] = self._getMovementResourceList()
""" return self.portal_simulation.getMovementHistoryStat(**kw)
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_zGetInventory(resource = self._getMovementResourceList(),
from_date=from_date,
to_date=to_date,
section=section,
node=node,
payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category, **kw)
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryList')
def getInventoryHistoryList(self, from_date = None, to_date=None, section = None, node = None, payment = None,
node_category=None, section_category=None, payment_category = None, simulation_state=None,
ignore_variation=0, **kw):
"""
Returns list of inventory grouped by section or site
"""
# Get Movement List
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_getInventoryHistoryList( resource = self._getMovementResourceList(),
from_date=from_date,
to_date=to_date,
section=section,
node=node,
payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category,
simulation_state = simulation_state,
**kw)
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryChart')
def getInventoryHistoryChart(self, from_date = None, to_date=None, section = None, node = None, payment = None,
node_category=None, section_category=None, payment_category = None, simulation_state=None,
ignore_variation=0, **kw):
"""
Returns list of inventory grouped by section or site
"""
# Get Movement List
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_getInventoryHistoryChart( resource = self._getMovementResourceList(),
from_date=from_date,
to_date=to_date,
section=section,
node=node,
payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category,
simulation_state = simulation_state,
**kw)
return result
security.declareProtected(Permissions.AccessContentsInformation, 'collectMovement') security.declareProtected(Permissions.AccessContentsInformation, 'collectMovement')
def collectMovement(self, movement_list): def collectMovement(self, movement_list):
......
...@@ -99,7 +99,7 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -99,7 +99,7 @@ class Resource(XMLMatrix, CoreResource, Variated):
o = o_brain.getObject() o = o_brain.getObject()
for v in o.getVariationBaseCategoryList(): for v in o.getVariationBaseCategoryList():
if base_category_list is () or v in base_category_list: if base_category_list is () or v in base_category_list:
display_value = getattr(o, display_id) display_value = getattr(o, display_id)
if callable( display_value ): if callable( display_value ):
display_value = display_value() display_value = display_value()
...@@ -195,465 +195,185 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -195,465 +195,185 @@ class Resource(XMLMatrix, CoreResource, Variated):
# Stock Management # Stock Management
security.declareProtected(Permissions.AccessContentsInformation, 'getInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getInventory')
def getInventory(self, at_date = None, def getInventory(self, **kw):
section = None, node = None, payment = None,
node_category=None, section_category=None, payment_category = None,
simulation_state=None, variation_text=None,
ignore_variation=0, standardise=0, **kw):
"""
resource (only in generic API in simulation)
from_date (>=) -
to_date (<) -
at_date (<=) - only take rows which date is <= at_date
section - only take rows in stock table which section_uid is equivalent to section
node - only take rows in stock table which node_uid is equivalent to node
payment - only take rows in stock table which payment_uid is equivalent to payment
mirror_section
section_category - only take rows in stock table which section_uid is in section_category
node_category - only take rows in stock table which node_uid is in section_category
payment_category - only take rows in stock table which payment_uid is in section_category
mirror_section_category
simulation_state - only take rows in stock table with specified simulation_state
variation_text - only take rows in stock table with specified variation_text
this needs to be extended with some kind of variation_category ?
XXX this way of implementing variation selection is far from perfect
variation_category - variation or list of possible variations
ignore_variation - do not take into account variation in inventory calculation
standardise - provide a standard quantity rather than an SKU
standardise_quantity
omit_input
omit_output
query - not the propper name - we now use selection_domain and selection_report
(refer to catalog)
**kw - if we want extended selection with more keywords (but bad performance)
check what we can do with buildSqlQuery
"""
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'):
simulation_state = [simulation_state]
result = self.Resource_zGetInventory(resource_uid = [self.getUid()],
resource=None,
to_date=at_date,
section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category, payment_category=payment_category,
simulation_state=simulation_state,
variation_text=variation_text
)
if len(result) > 0:
return result[0].inventory
return 0.0
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventory')
def getFutureInventory(self, section = None, node = None, payment = None,
node_category=None, section_category=None, payment_category = None, simulation_state=None,
ignore_variation=0, **kw):
""" """
Returns inventory at infinite Returns inventory
""" """
if section_category is None: kw['resource'] = self.getRelativeUrl()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getInventory(**kw)
return self.getInventory(at_date=None, section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category,
simulation_state=list(self.getPortalFutureInventoryStateList())+ \
list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList()),
**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory')
def getCurrentInventory(self, section = None, node = None, payment = None, def getCurrentInventory(**kw):
node_category=None, section_category=None, payment_category = None, ignore_variation=0, variation_text=None, **kw):
""" """
Returns current inventory Returns current inventory
""" """
kw['resource'] = self.getRelativeUrl()
# Consider only delivered - forget date at this point return self.portal_simulation.getCurrentInventory(**kw)
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventory(simulation_state = self.getPortalCurrentInventoryStateList(),
section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
#return self.getInventory(at_date=DateTime(), section=section, node=node, payment=payment,
# node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventory')
def getAvailableInventory(self, section = None, node = None, payment = None, def getAvailableInventory(**kw):
node_category=None, section_category=None, payment_category = None,
ignore_variation=0, **kw):
""" """
Returns available inventory, ie. current inventory - deliverable Returns available inventory
(current inventory - deliverable)
""" """
if section_category is None: kw['resource'] = self.getRelativeUrl()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getAvailableInventory(**kw)
return self.getInventory(at_date=DateTime(), section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventory')
def getInventoryList(self, at_date = None, section = None, node = None, payment = None, def getFutureInventory(**kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None, """
ignore_variation=0, **kw): Returns inventory at infinite
""" """
Returns list of inventory grouped by section or site kw['resource'] = self.getRelativeUrl()
""" return self.portal_simulation.getFutureInventory(**kw)
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'):
simulation_state = [simulation_state]
result = self.Resource_zGetInventoryList(resource_uid = [self.getUid()],
resource=None,
to_date=at_date,
section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category, payment_category=payment_category,
simulation_state=simulation_state,
**kw)
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryList')
def getFutureInventoryList(self, section = None, node = None, payment = None, def getInventoryList(self, **kw):
node_category=None, section_category=None, payment_category = None, """
simulation_state=None, ignore_variation=0, **kw): Returns list of inventory grouped by section or site
""" """
Returns list of future inventory grouped by section or site kw['resource'] = self.getRelativeUrl()
""" return self.portal_simulation.getInventoryList(**kw)
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
LOG('getFutureInventoryList',0,str(kw))
return self.getInventoryList(at_date=None, section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category,
simulation_state=list(self.getPortalFutureInventoryStateList())+ \
list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList()),
**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryList')
def getCurrentInventoryList(self, section = None, node = None, payment = None, def getCurrentInventoryList(**kw):
node_category=None, section_category=None, payment_category = None,
ignore_variation=0, **kw):
""" """
Returns list of current inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None: kw['resource'] = self.getRelativeUrl()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getCurrentInventoryList(**kw)
return self.getInventoryList(simulation_state=self.getPortalCurrentInventoryStateList(),
section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
#return self.getInventoryList(at_date=DateTime(), section=section, node=node, payment=payment,
# node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryList')
def getInventoryStat(self, at_date = None, section = None, node = None, payment = None, def getFutureInventoryList(**kw):
node_category=None, section_category=None, payment_category = None, """
simulation_state=None, ignore_variation=0, **kw): Returns list of inventory grouped by section or site
""" """
Returns statistics of inventory list grouped by section or site kw['resource'] = self.getRelativeUrl()
""" return self.portal_simulation.getFutureInventoryList(**kw)
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'):
simulation_state = [simulation_state]
result = self.Resource_zGetInventory(resource_uid = [self.getUid()],
resource=None,
to_date=at_date,
section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category, payment_category=payment_category,
simulation_state=simulation_state,
**kw)
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryStat')
def getFutureInventoryStat(self, section = None, node = None, payment = None, def getInventoryStat(self, **kw):
node_category=None, section_category=None, payment_category = None,
simulation_state=None, ignore_variation=0, **kw):
""" """
Returns statistics of future inventory list grouped by section or site Returns statistics of inventory grouped by section or site
""" """
if section_category is None: kw['resource'] = self.getRelativeUrl()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getInventoryStat(**kw)
return self.getInventoryStat(at_date=None, section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category,
simulation_state=list(self.getPortalFutureInventoryStateList())+ \
list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList()),
**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryStat') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryStat')
def getCurrentInventoryStat(self, section = None, node = None, payment = None, def getCurrentInventoryStat(**kw):
node_category=None, section_category=None, payment_category = None,
ignore_variation=0, **kw):
""" """
Returns statistics of current inventory list grouped by section or site Returns statistics of inventory grouped by section or site
""" """
if section_category is None: kw['resource'] = self.getRelativeUrl()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getCurrentInventoryStat(**kw)
return self.getInventoryStat(simulation_state=self.getPortalCurrentInventoryStateList(),
section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryStat')
def getInventoryChart(self, at_date = None, section = None, node = None, payment = None, def getFutureInventoryStat(**kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None, """
ignore_variation=0, **kw): Returns statistics of inventory grouped by section or site
""" """
Returns list of inventory grouped by section or site kw['resource'] = self.getRelativeUrl()
""" return self.portal_simulation.getFutureInventoryStat(**kw)
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'):
simulation_state = [simulation_state]
result = self.Resource_zGetInventoryList(resource_uid = [self.getUid()],
resource=None,
to_date=at_date,
section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category, payment_category=payment_category,
simulation_state=simulation_state,
**kw)
return map(lambda r: (r.node_title, r.inventory), result)
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryChart')
def getFutureInventoryChart(self, section = None, node = None, payment = None, def getInventoryChart(self, **kw):
node_category=None, section_category=None, payment_category = None,
simulation_state=None, ignore_variation=0, **kw):
""" """
Returns list of future inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None: kw['resource'] = self.getRelativeUrl()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getInventoryChart(**kw)
return self.getInventoryChart(at_date=None, section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category,
simulation_state=list(self.getPortalFutureInventoryStateList())+ \
list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList()),
**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryChart')
def getCurrentInventoryChart(self, section = None, node = None, payment = None, def getCurrentInventoryChart(**kw):
node_category=None, section_category=None, payment_category = None,
ignore_variation=0, **kw):
""" """
Returns list of current inventory grouped by section or site Returns list of inventory grouped by section or site
""" """
if section_category is None: kw['resource'] = self.getRelativeUrl()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getCurrentInventoryChart(**kw)
return self.getInventoryChart(simulation_state=self.getPortalCurrentInventoryStateList(),
section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
#return self.getInventoryChart(at_date=DateTime(), section=section, node=node, payment=payment,
# node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryChart')
def getMovementHistoryList(self, from_date = None, to_date=None, section = None, node = None, payment = None, def getFutureInventoryChart(**kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None, """
ignore_variation=0, **kw): Returns list of inventory grouped by section or site
""" """
Returns list of inventory grouped by section or site kw['resource'] = self.getRelativeUrl()
""" return self.portal_simulation.getFutureInventoryChart(**kw)
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_zGetMovementHistoryList(resource_uid = [self.getUid()],
resource=None,
from_date=from_date,
to_date=to_date,
section=section,
node=node, payment=payment,
node_category=node_category,
section_category=section_category, payment_category=payment_category,
simulation_state=simulation_state,
**kw)
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryStat')
def getMovementHistoryStat(self, from_date = None, to_date=None, section = None, node = None, payment = None,
node_category=None, section_category=None, payment_category = None, simulation_state=None,
ignore_variation=0, **kw):
"""
Returns list of inventory grouped by section or site
"""
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_zGetInventory(resource_uid = [self.getUid()],
resource=None,
from_date=from_date,
to_date=to_date,
section=section,
node=node, payment=payment,
node_category=node_category,
simulation_state=simulation_state,
section_category=section_category, payment_category=payment_category, **kw)
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryList')
def getInventoryHistoryList(self, from_date = None, to_date=None, section = None, node = None, payment = None, def getInventoryHistoryList(**kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None, """
ignore_variation=0, **kw): Returns list of inventory grouped by section or site
""" """
Returns list of inventory grouped by section or site kw['resource'] = self.getRelativeUrl()
""" return self.portal_simulation.getInventoryHistoryList(**kw)
# Get Movement List
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_getInventoryHistoryList( resource_uid = [self.getUid()],
resource=None,
from_date=from_date,
to_date=to_date,
section=section,
node=node, payment=payment,
node_category=node_category,
section_category=section_category, payment_category=payment_category,
simulation_state = simulation_state,
**kw)
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryChart') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryHistoryChart')
def getInventoryHistoryChart(self, from_date = None, to_date=None, section = None, node = None, payment = None, def getInventoryHistoryChart(**kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None, """
ignore_variation=0, **kw): Returns list of inventory grouped by section or site
""" """
Returns list of inventory grouped by section or site kw['resource'] = self.getRelativeUrl()
""" return self.portal_simulation.getInventoryHistoryChart(**kw)
# Get Movement List
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
result = self.Resource_getInventoryHistoryChart( resource_uid = [self.getUid()],
resource=None,
from_date=from_date,
to_date=to_date,
section=section,
node=node, payment=payment,
node_category=node_category,
section_category=section_category, payment_category=payment_category,
simulation_state = simulation_state,
**kw)
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryList')
def getMovementHistoryList(**kw):
"""
Returns list of inventory grouped by section or site
"""
kw['resource'] = self.getRelativeUrl()
return self.portal_simulation.getMovementHistoryList(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getNextNegativeInventoryDate') security.declareProtected(Permissions.AccessContentsInformation, 'getMovementHistoryStat')
def getNextNegativeInventoryDate(self, from_date = None, section = None, node = None, payment = None, def getMovementHistoryStat(**kw):
node_category=None, section_category=None, payment_category = None, simulation_state=None, """
variation_text = None, Returns list of inventory grouped by section or site
ignore_variation=0, **kw): """
""" kw['resource'] = self.getRelativeUrl()
Returns list of inventory grouped by section or site return self.portal_simulation.getMovementHistoryStat(**kw)
"""
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if from_date is None: from_date = DateTime()
# Get Movement List
result = self.Resource_getInventoryHistoryList( resource_uid = [self.getUid()],
resource=None,
from_date=from_date,
variation_text = variation_text,
section=section,
node=node, payment=payment,
node_category=node_category,
section_category=section_category,
payment_category=payment_category,
simulation_state = simulation_state,
**kw)
for inventory in result:
if inventory['inventory'] < 0:
return inventory['stop_date']
return None security.declareProtected(Permissions.AccessContentsInformation, 'getNextNegativeInventoryDate')
def getNextNegativeInventoryDate(**kw):
"""
Returns list of inventory grouped by section or site
"""
kw['resource'] = self.getRelativeUrl()
return self.portal_simulation.getNextNegativeInventoryDate(**kw)
# Asset price API # Asset Price API
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryAssetPrice') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoryAssetPrice')
def getInventoryAssetPrice(self, at_date = None, section = None, node = None, payment = None, def getInventoryAssetPrice(**kw):
node_category=None, section_category=None, payment_category = None,
simulation_state=None, variation_text=None,
ignore_variation=0, standardise=0, **kw):
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
if type(simulation_state) is type('a'):
simulation_state = [simulation_state]
result = self.Resource_zGetInventory(resource_uid = [self.getUid()],
resource=None,
to_date=at_date,
section=section, node=node, payment=payment,
node_category=node_category,
section_category=section_category, payment_category=payment_category,
simulation_state=simulation_state,
variation_text=variation_text
)
if len(result) > 0:
return result[0].inventory
return 0.0
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryAssetPrice')
def getFutureInventoryAssetPrice(self, section = None, node = None, payment = None,
node_category=None, section_category=None, payment_category = None, simulation_state=None,
ignore_variation=0, **kw):
""" """
Returns inventory asset price at infinite Returns list of inventory grouped by section or site
""" """
if section_category is None: kw['resource'] = self.getRelativeUrl()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getInventoryAssetPrice(**kw)
return self.getInventoryAssetPrice(at_date=None, section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category,
simulation_state=list(self.getPortalFutureInventoryStateList())+ \
list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList()),
**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryAssetPrice') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventoryAssetPrice')
def getCurrentInventoryAssetPrice(self, section = None, node = None, payment = None, def getCurrentInventoryAssetPrice(**kw):
node_category=None, section_category=None, payment_category = None, ignore_variation=0, variation_text=None, **kw):
""" """
Returns current inventory asset price Returns list of inventory grouped by section or site
""" """
kw['resource'] = self.getRelativeUrl()
# Consider only delivered - forget date at this point return self.portal_simulation.getCurrentInventoryAssetPrice(**kw)
if section_category is None:
section_category = self.getPortalDefaultSectionCategory()
return self.getInventoryAssetPrice(simulation_state = self.getPortalCurrentInventoryStateList(),
section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
#return self.getInventory(at_date=DateTime(), section=section, node=node, payment=payment,
# node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventoryAssetPrice') security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableInventoryAssetPrice')
def getAvailableInventoryAssetPrice(self, section = None, node = None, payment = None, def getAvailableInventoryAssetPrice(**kw):
node_category=None, section_category=None, payment_category = None, """
ignore_variation=0, **kw): Returns list of inventory grouped by section or site
"""
kw['resource'] = self.getRelativeUrl()
return self.portal_simulation.getAvailableInventoryAssetPrice(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getFutureInventoryAssetPrice')
def getFutureInventoryAssetPrice(**kw):
""" """
Returns available inventory asset price, ie. current inventory - deliverable Returns list of inventory grouped by section or site
""" """
if section_category is None: kw['resource'] = self.getRelativeUrl()
section_category = self.getPortalDefaultSectionCategory() return self.portal_simulation.getFutureInventoryAssetPrice(**kw)
return self.getInventoryAssetPrice(at_date=DateTime(), section=section, node=node, payment=payment,
node_category=node_category, section_category=section_category, payment_category=payment_category, **kw)
# Industrial price API # Industrial price API
security.declareProtected(Permissions.AccessContentsInformation, 'getIndustrialPrice') security.declareProtected(Permissions.AccessContentsInformation, 'getIndustrialPrice')
def getIndustrialPrice(self, context=None, REQUEST=None, **kw): def getIndustrialPrice(self, context=None, REQUEST=None, **kw):
...@@ -712,7 +432,7 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -712,7 +432,7 @@ class Resource(XMLMatrix, CoreResource, Variated):
# i did not do anything, because where is maybe some method for continuous range (Romain) # i did not do anything, because where is maybe some method for continuous range (Romain)
# XXX why creating all cells ? it takes too much time and is not very useful (Romain) # XXX why creating all cells ? it takes too much time and is not very useful (Romain)
# and it is not updated when we create a variation # and it is not updated when we create a variation
# and Base_edit does not create such cell.... # and Base_edit does not create such cell....
""" """
cell_range_key_list = self.getCellRangeKeyList(base_id = base_id) cell_range_key_list = self.getCellRangeKeyList(base_id = base_id)
...@@ -760,7 +480,7 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -760,7 +480,7 @@ class Resource(XMLMatrix, CoreResource, Variated):
p.setCriterionPropertyList(('quantity', )) p.setCriterionPropertyList(('quantity', ))
p.setCriterion('quantity', min=None, max=value[i]) p.setCriterion('quantity', min=None, max=value[i])
p.setTitle(' quantity < %s' % repr(value[i])) p.setTitle(' quantity < %s' % repr(value[i]))
for i in range(0, len(value) -1 ): for i in range(0, len(value) -1 ):
p = self.newContent(id = 'quantity_range_%s' % str(i+1), portal_type = 'Predicate Group') p = self.newContent(id = 'quantity_range_%s' % str(i+1), portal_type = 'Predicate Group')
p.setCriterionPropertyList(('quantity', )) p.setCriterionPropertyList(('quantity', ))
......
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