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
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):
"""
A mix-in class which provides some utilities
......@@ -420,12 +419,23 @@ class Amount(Base, Variated):
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):
......
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