Commit 59f14dea authored by Vincent Pelletier's avatar Vincent Pelletier

InventoryBrain: Do not use getToolByName.

Also, factorise code.
parent 7dbee586
...@@ -52,33 +52,28 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin): ...@@ -52,33 +52,28 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
Lists each variation Lists each variation
""" """
# Stock management # Stock management
def getInventory(self, **kw): def _callSimulationTool(self, method_id, **kw):
simulation_tool = getToolByName(self, 'portal_simulation') return getattr(
return simulation_tool.getInventory( self.getPortalObject().portal_simulation,
method_id,
)(
node_uid=self.node_uid, node_uid=self.node_uid,
variation_text=self.variation_text, variation_text=self.variation_text,
resource_uid=self.resource_uid, **kw) resource_uid=self.resource_uid,
**kw
)
def getCurrentInventory(self,**kw): def getInventory(self, **kw):
simulation_tool = getToolByName(self, 'portal_simulation') return self._callSimulationTool('getInventory', **kw)
return simulation_tool.getCurrentInventory(
node_uid=self.node_uid, def getCurrentInventory(self, **kw):
variation_text=self.variation_text, return self._callSimulationTool('getCurrentInventory', **kw)
resource_uid=self.resource_uid, **kw)
def getFutureInventory(self,**kw): def getFutureInventory(self,**kw):
simulation_tool = getToolByName(self,'portal_simulation') return self._callSimulationTool('getFutureInventory', **kw)
return simulation_tool.getFutureInventory(
node_uid=self.node_uid,
variation_text=self.variation_text,
resource_uid=self.resource_uid, **kw)
def getAvailableInventory(self,**kw): def getAvailableInventory(self,**kw):
simulation_tool = getToolByName(self,'portal_simulation') return self._callSimulationTool('getAvailableInventory', **kw)
return simulation_tool.getAvailableInventory(
node_uid=self.node_uid,
variation_text=self.variation_text,
resource_uid=self.resource_uid, **kw)
def getQuantityUnit(self, **kw): def getQuantityUnit(self, **kw):
resource = self.getResourceValue() resource = self.getResourceValue()
......
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