Commit 267389fa authored by Jean-Paul Smets's avatar Jean-Paul Smets

Added setters for net and converted quantities


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@157 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 24381b2e
...@@ -178,6 +178,18 @@ class Amount(Base, Variated): ...@@ -178,6 +178,18 @@ class Amount(Base, Variated):
converted_quantity = None converted_quantity = None
return converted_quantity return converted_quantity
security.declareProtected(Permissions.ModifyPortalContent, 'setConvertedQuantity')
def setConvertedQuantity(self, value):
try:
#if 1:
resource = self.getResourceValue()
resource_quantity_unit = resource.getDefaultQuantityUnit()
quantity_unit = self.getQuantityUnit()
quantity = resource.convertQuantity(value, resource_quantity_unit, quantity_unit)
self.setQuantity(quantity)
except:
LOG("ERP5 WARNING:", 100, 'could not set converted quantity for %s' % self.getRelativeUrl())
security.declareProtected(Permissions.AccessContentsInformation, 'getConvertedTargetQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getConvertedTargetQuantity')
def getConvertedTargetQuantity(self): def getConvertedTargetQuantity(self):
""" """
...@@ -194,6 +206,18 @@ class Amount(Base, Variated): ...@@ -194,6 +206,18 @@ class Amount(Base, Variated):
converted_quantity = None converted_quantity = None
return converted_quantity return converted_quantity
security.declareProtected(Permissions.ModifyPortalContent, 'setConvertedTargetQuantity')
def setConvertedTargetQuantity(self, value):
try:
#if 1:
resource = self.getResourceValue()
resource_quantity_unit = resource.getDefaultQuantityUnit()
quantity_unit = self.getQuantityUnit()
quantity = resource.convertQuantity(value, resource_quantity_unit, quantity_unit)
self.setTargetQuantity(quantity)
except:
LOG("ERP5 WARNING:", 100, 'could not set converted quantity for %s' % self.getRelativeUrl())
security.declareProtected(Permissions.AccessContentsInformation, 'getNetQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getNetQuantity')
def getNetQuantity(self): def getNetQuantity(self):
""" """
...@@ -230,6 +254,18 @@ class Amount(Base, Variated): ...@@ -230,6 +254,18 @@ class Amount(Base, Variated):
else: else:
return None return None
security.declareProtected(Permissions.ModifyPortalContent, 'setNetConvertedQuantity')
def setNetConvertedQuantity(self, value):
"""
Take into account efficiency in converted quantity
"""
efficiency = self.getEfficiency()
if efficiency in (0, 0.0, None):
efficiency = 1.0
if value is not None:
quantity = float(value) * efficiency
self.setConvertedQuantity(quantity)
security.declareProtected(Permissions.AccessContentsInformation, 'getNetConvertedTargetQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getNetConvertedTargetQuantity')
def getNetConvertedTargetQuantity(self): def getNetConvertedTargetQuantity(self):
""" """
...@@ -244,6 +280,18 @@ class Amount(Base, Variated): ...@@ -244,6 +280,18 @@ class Amount(Base, Variated):
else: else:
return None return None
security.declareProtected(Permissions.ModifyPortalContent, 'setNetConvertedTargetQuantity')
def setNetConvertedTargetQuantity(self, value):
"""
Take into account efficiency in converted quantity
"""
efficiency = self.getEfficiency()
if efficiency in (0, 0.0, None):
efficiency = 1.0
if value is not None:
quantity = float(value) * efficiency
self.setConvertedTargetQuantity(quantity)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoriatedQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoriatedQuantity')
def getInventoriatedQuantity(self): def getInventoriatedQuantity(self):
""" """
......
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