From dd6a64e4b61015254c9fddaa3d415f1ba1bb0e92 Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet <nicolas.dumazet@nexedi.com> Date: Fri, 23 Jul 2010 11:11:16 +0000 Subject: [PATCH] add compatibility accessors for quantity_unit git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37254 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/Amount.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/product/ERP5/Document/Amount.py b/product/ERP5/Document/Amount.py index e23bfe34fe..a32cc5e27e 100644 --- a/product/ERP5/Document/Amount.py +++ b/product/ERP5/Document/Amount.py @@ -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 + -- 2.30.9