[Erp5-report] r37254 nicolas.dumazet - /erp5/trunk/products/ERP5/Document/Amount.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jul 23 13:11:17 CEST 2010


Author: nicolas.dumazet
Date: Fri Jul 23 13:11:16 2010
New Revision: 37254

URL: http://svn.erp5.org?rev=37254&view=rev
Log:
add compatibility accessors for quantity_unit

Modified:
    erp5/trunk/products/ERP5/Document/Amount.py

Modified: erp5/trunk/products/ERP5/Document/Amount.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Amount.py?rev=37254&r1=37253&r2=37254&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Amount.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Amount.py [utf8] Fri Jul 23 13:11:16 2010
@@ -40,6 +40,7 @@ from Products.ERP5Type.TransactionalVari
 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
+




More information about the Erp5-report mailing list