Commit b7289eb0 authored by Sebastien Robin's avatar Sebastien Robin

make setConsumptionQuantity and setProductionQuantity working


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4382 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b693234a
...@@ -490,10 +490,11 @@ class Amount(Base, Variated): ...@@ -490,10 +490,11 @@ class Amount(Base, Variated):
# Helper methods to display quantities as produced / consumed # Helper methods to display quantities as produced / consumed
security.declareProtected(Permissions.AccessContentsInformation, 'getProductionQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getProductionQuantity')
def getProductionQuantity(self): def getProductionQuantity(self,quantity=None):
""" """
Return the produced quantity Return the produced quantity
""" """
if quantity is None:
quantity = self.getQuantity() quantity = self.getQuantity()
source = self.getSource() source = self.getSource()
destination = self.getDestination() destination = self.getDestination()
...@@ -516,10 +517,11 @@ class Amount(Base, Variated): ...@@ -516,10 +517,11 @@ class Amount(Base, Variated):
return 0.0 return 0.0
security.declareProtected(Permissions.AccessContentsInformation, 'getConsumptionQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getConsumptionQuantity')
def getConsumptionQuantity(self): def getConsumptionQuantity(self,quantity=None):
""" """
Return the produced quantity Return the consumption quantity
""" """
if quantity is None:
quantity = self.getQuantity() quantity = self.getQuantity()
source = self.getSource() source = self.getSource()
destination = self.getDestination() destination = self.getDestination()
...@@ -548,6 +550,7 @@ class Amount(Base, Variated): ...@@ -548,6 +550,7 @@ class Amount(Base, Variated):
""" """
source = self.getSource() source = self.getSource()
destination = self.getDestination() destination = self.getDestination()
quantity = value
if quantity is not None: if quantity is not None:
quantity = float(quantity) quantity = float(quantity)
...@@ -557,14 +560,10 @@ class Amount(Base, Variated): ...@@ -557,14 +560,10 @@ class Amount(Base, Variated):
if source in (None, ''): if source in (None, ''):
if quantity >= 0: if quantity >= 0:
self.setQuantity(quantity) self.setQuantity(quantity)
else:
return 0.0
if destination in (None, ''): if destination in (None, ''):
if quantity >= 0: if quantity >= 0:
self.setQuantity(- quantity) self.setQuantity(- quantity)
else:
return 0.0
security.declareProtected(Permissions.ModifyPortalContent, 'setConsumptionQuantity') security.declareProtected(Permissions.ModifyPortalContent, 'setConsumptionQuantity')
def setConsumptionQuantity(self, value): def setConsumptionQuantity(self, value):
...@@ -573,6 +572,7 @@ class Amount(Base, Variated): ...@@ -573,6 +572,7 @@ class Amount(Base, Variated):
""" """
source = self.getSource() source = self.getSource()
destination = self.getDestination() destination = self.getDestination()
quantity = value
if quantity is not None: if quantity is not None:
quantity = float(quantity) quantity = float(quantity)
...@@ -582,14 +582,10 @@ class Amount(Base, Variated): ...@@ -582,14 +582,10 @@ class Amount(Base, Variated):
if destination in (None, ''): if destination in (None, ''):
if quantity >= 0: if quantity >= 0:
self.setQuantity(quantity) self.setQuantity(quantity)
else:
return 0.0
if source in (None, ''): if source in (None, ''):
if quantity >= 0: if quantity >= 0:
self.setQuantity(- quantity) self.setQuantity(- quantity)
else:
return 0.0
# Inventory # Inventory
security.declareProtected(Permissions.AccessContentsInformation, 'getConvertedInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getConvertedInventory')
......
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