Commit 0f53fe50 authored by Romain Courteaud's avatar Romain Courteaud

Changed code layout.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5032 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9c87ee38
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
from Products.ZSQLCatalog.zsqlbrain import ZSQLBrain from Products.ZSQLCatalog.zsqlbrain import ZSQLBrain
from DateTime import DateTime from DateTime import DateTime
from ZTUtils import make_query from ZTUtils import make_query
...@@ -23,14 +22,15 @@ class InventoryBrain(ZSQLBrain): ...@@ -23,14 +22,15 @@ class InventoryBrain(ZSQLBrain):
""" """
Global analysis (all variations and categories) Global analysis (all variations and categories)
""" """
# Stock management # Stock management
def getInventory(self, at_date = None, ignore_variation=0, simulation_state=None, **kw): def getInventory(self, at_date = None, ignore_variation=0,
simulation_state=None, **kw):
if type(simulation_state) is type('a'): if type(simulation_state) is type('a'):
simulation_state = [simulation_state] simulation_state = [simulation_state]
result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], result = self.Resource_zGetInventory(
to_date=at_date, omit_simulation = 0, resource_uid=[self.resource_uid],
section_category = self.getPortalDefaultSectionCategory(), to_date=at_date, omit_simulation=0,
section_category=self.getPortalDefaultSectionCategory(),
simulation_state=simulation_state) simulation_state=simulation_state)
inventory = None inventory = None
if len(result) > 0: if len(result) > 0:
...@@ -40,20 +40,22 @@ class InventoryBrain(ZSQLBrain): ...@@ -40,20 +40,22 @@ class InventoryBrain(ZSQLBrain):
else: else:
return inventory return inventory
#getCurrentInventory = 10.0
def getCurrentInventory(self): def getCurrentInventory(self):
""" """
Returns current inventory Returns current inventory
""" """
return self.getInventory(simulation_state=self.getPortalCurrentInventoryStateList(), ignore_variation=1) return self.getInventory(
#return self.getInventory(at_date=DateTime(), ignore_variation=1) simulation_state=self.getPortalCurrentInventoryStateList(),
ignore_variation=1)
def getFutureInventory(self): def getFutureInventory(self):
""" """
Returns current inventory Returns current inventory
""" """
return self.getInventory(ignore_variation=1, return self.getInventory(
simulation_state=list(self.getPortalFutureInventoryStateList())+ \ ignore_variation=1,
simulation_state= \
list(self.getPortalFutureInventoryStateList())+ \
list(self.getPortalReservedInventoryStateList())+ \ list(self.getPortalReservedInventoryStateList())+ \
list(self.getPortalCurrentInventoryStateList())) list(self.getPortalCurrentInventoryStateList()))
...@@ -63,10 +65,12 @@ class InventoryBrain(ZSQLBrain): ...@@ -63,10 +65,12 @@ class InventoryBrain(ZSQLBrain):
""" """
at_date=DateTime() at_date=DateTime()
current = self.getCurrentInventory() current = self.getCurrentInventory()
result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], ignore_variation=1, result = self.Resource_zGetInventory(
omit_simulation = 1, omit_input = 1, resource_uid=[self.resource_uid], ignore_variation=1,
section_category = self.getPortalDefaultSectionCategory(), omit_simulation=1, omit_input=1,
simulation_state = self.getPortalReservedInventoryStateList()) section_category=self.getPortalDefaultSectionCategory(),
simulation_state= \
self.getPortalReservedInventoryStateList())
reserved_inventory = None reserved_inventory = None
if len(result) > 0: if len(result) > 0:
reserved_inventory = result[0].inventory reserved_inventory = result[0].inventory
...@@ -76,12 +80,12 @@ class InventoryBrain(ZSQLBrain): ...@@ -76,12 +80,12 @@ class InventoryBrain(ZSQLBrain):
def getQuantityUnit(self, **kw): def getQuantityUnit(self, **kw):
try: try:
resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url) resource = self.portal_categories.unrestrictedTraverse(
self.resource_relative_url)
return resource.getQuantityUnit() return resource.getQuantityUnit()
except AttributeError: except AttributeError:
return '' return ''
class InventoryListBrain(ZSQLBrain): class InventoryListBrain(ZSQLBrain):
""" """
Lists each variation Lists each variation
...@@ -93,25 +97,30 @@ class InventoryListBrain(ZSQLBrain): ...@@ -93,25 +97,30 @@ class InventoryListBrain(ZSQLBrain):
Returns the inventory Returns the inventory
""" """
simulation_tool = getToolByName(self,'portal_simulation') simulation_tool = getToolByName(self,'portal_simulation')
return simulation_tool.getInventory(node=self.node_relative_url,variation_text=self.variation_text, return simulation_tool.getInventory(
resource=self.resource_relative_url,**kw) node=self.node_relative_url,
variation_text=self.variation_text,
resource=self.resource_relative_url, **kw)
#getCurrentInventory = 10.0
def getCurrentInventory(self,**kw): def getCurrentInventory(self,**kw):
""" """
Returns current inventory Returns current inventory
""" """
simulation_tool = getToolByName(self,'portal_simulation') simulation_tool = getToolByName(self,'portal_simulation')
return simulation_tool.getCurrentInventory(node=self.node_relative_url,variation_text=self.variation_text, return simulation_tool.getCurrentInventory(
resource=self.resource_relative_url,**kw) node=self.node_relative_url,
variation_text=self.variation_text,
resource=self.resource_relative_url, **kw)
def getFutureInventory(self,**kw): def getFutureInventory(self,**kw):
""" """
Returns current inventory Returns current inventory
""" """
simulation_tool = getToolByName(self,'portal_simulation') simulation_tool = getToolByName(self,'portal_simulation')
return simulation_tool.getFutureInventory(node=self.node_relative_url,variation_text=self.variation_text, return simulation_tool.getFutureInventory(
resource=self.resource_relative_url,**kw) node=self.node_relative_url,
variation_text=self.variation_text,
resource=self.resource_relative_url, **kw)
def getAvailableInventory(self,**kw): def getAvailableInventory(self,**kw):
""" """
...@@ -260,14 +269,16 @@ class DeliveryListBrain(InventoryListBrain): ...@@ -260,14 +269,16 @@ class DeliveryListBrain(InventoryListBrain):
""" """
# Stock management # Stock management
def getInventory(self, at_date = None, ignore_variation=0, simulation_state=None, **kw): def getInventory(self, at_date=None, ignore_variation=0,
simulation_state=None, **kw):
if type(simulation_state) is type('a'): if type(simulation_state) is type('a'):
simulation_state = [simulation_state] simulation_state = [simulation_state]
if hasattr(self, 'where_expression'): if hasattr(self, 'where_expression'):
where_expression = self.where_expression where_expression = self.where_expression
else: else:
where_expression = None where_expression = None
result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], result = self.Resource_zGetInventory(
resource_uid = [self.resource_uid],
to_date=at_date, to_date=at_date,
section_category = self.getPortalDefaultSectionCategory(), section_category = self.getPortalDefaultSectionCategory(),
variation_text = self.variation_text, variation_text = self.variation_text,
...@@ -287,7 +298,8 @@ class DeliveryListBrain(InventoryListBrain): ...@@ -287,7 +298,8 @@ class DeliveryListBrain(InventoryListBrain):
""" """
at_date=DateTime() at_date=DateTime()
current = self.getCurrentInventory() current = self.getCurrentInventory()
result = self.Resource_zGetInventory( resource_uid = [self.resource_uid], result = self.Resource_zGetInventory(
resource_uid = [self.resource_uid],
omit_simulation = 1, omit_input = 1, omit_simulation = 1, omit_input = 1,
section_category = self.getPortalDefaultSectionCategory(), section_category = self.getPortalDefaultSectionCategory(),
variation_text = self.variation_text, variation_text = self.variation_text,
...@@ -305,5 +317,9 @@ class DeliveryListBrain(InventoryListBrain): ...@@ -305,5 +317,9 @@ class DeliveryListBrain(InventoryListBrain):
""" """
at_date=self.at_date at_date=self.at_date
LOG("At Date",0,str(at_date)) LOG("At Date",0,str(at_date))
return self.getInventory(at_date=at_date, ignore_variation=0, simulation_state=list(self.getPortalFutureInventoryStateList())+list(self.getPortalReservedInventoryStateList())+list(self.getPortalCurrentInventoryStateList())) return self.getInventory(
at_date=at_date, ignore_variation=0,
simulation_state= \
list(self.getPortalFutureInventoryStateList()) + \
list(self.getPortalReservedInventoryStateList()) + \
list(self.getPortalCurrentInventoryStateList()))
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