Commit dd6a64e4 authored by Nicolas Dumazet's avatar Nicolas Dumazet

add compatibility accessors for quantity_unit


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37254 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4c6a58b6
......@@ -40,6 +40,7 @@ from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from zLOG import LOG, ERROR
from warnings import warn
class Amount(Base, Variated):
"""
A mix-in class which provides some utilities
......@@ -716,3 +717,24 @@ class Amount(Base, Variated):
def _setLostQuantity(self, value):
return self._setProfitQuantity(- value)
## quantity_unit accessors for backward compatibility:
## (we used to acquire quantity_unit from the resources)
security.declareProtected(Permissions.AccessContentsInformation,
'getQuantityUnitValue')
def getQuantityUnitValue(self):
result = self.getDefaultValue('quantity_unit')
if result is None:
resource = self.getResourceValue()
if resource is not None:
result = resource.getQuantityUnitValue()
return result
security.declareProtected(Permissions.AccessContentsInformation,
'getQuantityUnit')
def getQuantityUnit(self):
value = self.getQuantityUnitValue()
if value is not None:
return value.getCategoryRelativeUrl()
return None
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