Commit 4320819e authored by Jérome Perrin's avatar Jérome Perrin

prefer uid over relative_url

Also remove copy pasted comments
parent 4df2c07f
...@@ -42,17 +42,11 @@ class InventoryBrain(ZSQLBrain): ...@@ -42,17 +42,11 @@ class InventoryBrain(ZSQLBrain):
return inventory return inventory
def getCurrentInventory(self): def getCurrentInventory(self):
"""
Returns current inventory
"""
return self.getInventory( return self.getInventory(
simulation_state=self.getPortalCurrentInventoryStateList(), simulation_state=self.getPortalCurrentInventoryStateList(),
ignore_variation=1) ignore_variation=1)
def getFutureInventory(self): def getFutureInventory(self):
"""
Returns current inventory
"""
return self.getInventory( return self.getInventory(
ignore_variation=1, ignore_variation=1,
simulation_state= \ simulation_state= \
...@@ -61,9 +55,6 @@ class InventoryBrain(ZSQLBrain): ...@@ -61,9 +55,6 @@ class InventoryBrain(ZSQLBrain):
list(self.getPortalCurrentInventoryStateList())) list(self.getPortalCurrentInventoryStateList()))
def getAvailableInventory(self): def getAvailableInventory(self):
"""
Returns current inventory
"""
at_date=DateTime() at_date=DateTime()
current = self.getCurrentInventory() current = self.getCurrentInventory()
result = self.Resource_zGetInventory( result = self.Resource_zGetInventory(
...@@ -80,12 +71,9 @@ class InventoryBrain(ZSQLBrain): ...@@ -80,12 +71,9 @@ class InventoryBrain(ZSQLBrain):
return current + reserved_inventory return current + reserved_inventory
def getQuantityUnit(self, **kw): def getQuantityUnit(self, **kw):
try: resource = self.portal_catalog.getObject(self.resource_uid)
resource = self.portal_categories.unrestrictedTraverse( if resource is not None:
self.resource_relative_url)
return resource.getQuantityUnit() return resource.getQuantityUnit()
except AttributeError:
return ''
class InventoryListBrain(ZSQLBrain): class InventoryListBrain(ZSQLBrain):
""" """
...@@ -94,52 +82,37 @@ class InventoryListBrain(ZSQLBrain): ...@@ -94,52 +82,37 @@ class InventoryListBrain(ZSQLBrain):
# Stock management # Stock management
def getInventory(self, **kw): def getInventory(self, **kw):
"""
Returns the inventory
"""
simulation_tool = getToolByName(self, 'portal_simulation') simulation_tool = getToolByName(self, 'portal_simulation')
return simulation_tool.getInventory( return simulation_tool.getInventory(
node=self.node_relative_url, node_uid=self.node_uid,
variation_text=self.variation_text, variation_text=self.variation_text,
resource=self.resource_relative_url, **kw) resource_uid=self.resource_uid, **kw)
def getCurrentInventory(self,**kw): def getCurrentInventory(self,**kw):
"""
Returns current inventory
"""
simulation_tool = getToolByName(self, 'portal_simulation') simulation_tool = getToolByName(self, 'portal_simulation')
return simulation_tool.getCurrentInventory( return simulation_tool.getCurrentInventory(
node=self.node_relative_url, node_uid=self.node_uid,
variation_text=self.variation_text, variation_text=self.variation_text,
resource=self.resource_relative_url, **kw) resource_uid=self.resource_uid, **kw)
def getFutureInventory(self,**kw): def getFutureInventory(self,**kw):
"""
Returns current inventory
"""
simulation_tool = getToolByName(self,'portal_simulation') simulation_tool = getToolByName(self,'portal_simulation')
return simulation_tool.getFutureInventory( return simulation_tool.getFutureInventory(
node=self.node_relative_url, node_uid=self.node_uid,
variation_text=self.variation_text, variation_text=self.variation_text,
resource=self.resource_relative_url, **kw) resource_uid=self.resource_uid, **kw)
def getAvailableInventory(self,**kw): def getAvailableInventory(self,**kw):
"""
Returns current inventory
"""
simulation_tool = getToolByName(self,'portal_simulation') simulation_tool = getToolByName(self,'portal_simulation')
return simulation_tool.getAvailableInventory( return simulation_tool.getAvailableInventory(
node=self.node_relative_url, node_uid=self.node_uid,
variation_text=self.variation_text, variation_text=self.variation_text,
resource=self.resource_relative_url, **kw) resource_uid=self.resource_uid, **kw)
def getQuantityUnit(self, **kw): def getQuantityUnit(self, **kw):
try: resource = self.portal_catalog.getObject(self.resource_uid)
resource = self.portal_categories.unrestrictedTraverse( if resource is not None:
self.resource_relative_url)
return resource.getQuantityUnit() return resource.getQuantityUnit()
except AttributeError:
return ''
def getListItemUrl(self, cname_id, selection_index, selection_name): def getListItemUrl(self, cname_id, selection_index, selection_name):
"""Returns the URL for column `cname_id`. Used by ListBox """Returns the URL for column `cname_id`. Used by ListBox
...@@ -159,10 +132,9 @@ class InventoryListBrain(ZSQLBrain): ...@@ -159,10 +132,9 @@ class InventoryListBrain(ZSQLBrain):
explanation.getRelativeUrl()) explanation.getRelativeUrl())
else: else:
return '' return ''
elif getattr(self, 'resource_relative_url', None) is not None: elif getattr(self, 'resource_uid', None) is not None:
# A resource is defined, so try to display the movement list # A resource is defined, so try to display the movement list
resource = self.portal_categories.unrestrictedTraverse( resource = self.portal_catalog.getObject(self.resource_uid)
self.resource_relative_url)
form_name = 'Resource_viewMovementHistory' form_name = 'Resource_viewMovementHistory'
query_kw = { query_kw = {
'variation_text': self.variation_text, 'variation_text': self.variation_text,
......
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