[Erp5-report] r32402 yo - /erp5/trunk/products/ERP5/Document/Amount.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Feb 10 11:03:43 CET 2010
Author: yo
Date: Wed Feb 10 11:03:39 2010
New Revision: 32402
URL: http://svn.erp5.org?rev=32402&view=rev
Log:
Stop causing an infinite loop on _getBaseUnitPrice.
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=32402&r1=32401&r2=32402&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Amount.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Amount.py [utf8] Wed Feb 10 11:03:39 2010
@@ -37,11 +37,10 @@
from Products.ERP5Type.Base import Base
from Products.ERP5Type.Base import TempBase
from Products.CMFCategory.Renderer import Renderer
-
+from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from zLOG import LOG, ERROR
from warnings import warn
-
class Amount(Base, Variated):
"""
@@ -420,12 +419,23 @@
return quantity * price
def _getBaseUnitPrice(self, context):
- resource = self.getResourceValue()
- if resource is not None:
- operand_dict = resource.getPriceParameterDict(context=context)
- if operand_dict is not None:
- base_unit_price = operand_dict.get('base_unit_price', None)
- return base_unit_price
+ # Stop any recursive call to this method. This happens when a Path
+ # does not have base unit price locally, so it looks it up, and
+ # each path of a predicate list does the same again.
+ tv = getTransactionalVariable(self)
+ key = '_getBaseUnitPrice'
+ if key in tv:
+ return
+ tv[key] = 1
+ try:
+ resource = self.getResourceValue()
+ if resource is not None:
+ operand_dict = resource.getPriceParameterDict(context=context)
+ if operand_dict is not None:
+ base_unit_price = operand_dict.get('base_unit_price', None)
+ return base_unit_price
+ finally:
+ del tv[key]
security.declareProtected(Permissions.AccessContentsInformation, 'getBaseUnitPrice')
def getBaseUnitPrice(self, **kw):
More information about the Erp5-report
mailing list