Commit 5c454ad1 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Stop causing an infinite loop on _getBaseUnitPrice.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32402 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0c341c29
...@@ -37,12 +37,11 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces ...@@ -37,12 +37,11 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from Products.ERP5Type.Base import TempBase from Products.ERP5Type.Base import TempBase
from Products.CMFCategory.Renderer import Renderer from Products.CMFCategory.Renderer import Renderer
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from zLOG import LOG, ERROR from zLOG import LOG, ERROR
from warnings import warn from warnings import warn
class Amount(Base, Variated): class Amount(Base, Variated):
""" """
A mix-in class which provides some utilities A mix-in class which provides some utilities
...@@ -420,12 +419,23 @@ class Amount(Base, Variated): ...@@ -420,12 +419,23 @@ class Amount(Base, Variated):
return quantity * price return quantity * price
def _getBaseUnitPrice(self, context): def _getBaseUnitPrice(self, context):
# 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() resource = self.getResourceValue()
if resource is not None: if resource is not None:
operand_dict = resource.getPriceParameterDict(context=context) operand_dict = resource.getPriceParameterDict(context=context)
if operand_dict is not None: if operand_dict is not None:
base_unit_price = operand_dict.get('base_unit_price', None) base_unit_price = operand_dict.get('base_unit_price', None)
return base_unit_price return base_unit_price
finally:
del tv[key]
security.declareProtected(Permissions.AccessContentsInformation, 'getBaseUnitPrice') security.declareProtected(Permissions.AccessContentsInformation, 'getBaseUnitPrice')
def getBaseUnitPrice(self, **kw): def getBaseUnitPrice(self, **kw):
......
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