Commit f9fe7ea9 authored by Sebastien Robin's avatar Sebastien Robin

moved getPrice from supplyLine

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3006 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 770e78d1
No related merge requests found
...@@ -39,6 +39,7 @@ from Products.ERP5.Core.Resource import Resource as CoreResource ...@@ -39,6 +39,7 @@ from Products.ERP5.Core.Resource import Resource as CoreResource
from Products.ERP5.Document.SupplyLine import SupplyLineMixin from Products.ERP5.Document.SupplyLine import SupplyLineMixin
from Products.CMFCore.WorkflowCore import WorkflowMethod from Products.CMFCore.WorkflowCore import WorkflowMethod
from Products.CMFCategory.Renderer import Renderer from Products.CMFCategory.Renderer import Renderer
from Products.CMFCore.utils import getToolByName
from zLOG import LOG from zLOG import LOG
...@@ -186,13 +187,8 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -186,13 +187,8 @@ class Resource(XMLMatrix, CoreResource, Variated):
base_category_list=base_category_list, base_category_list=base_category_list,
display_base_category=display_base_category, **kw) display_base_category=display_base_category, **kw)
if not omit_individual_variation: if not omit_individual_variation:
try: other_variations = self.searchFolder(
# XXX Why catching exception here ? portal_type=self.getPortalVariationTypeList())
# Can searchFolder crach ? Or just getPortalVariationTypeList ?
other_variations = self.searchFolder(
portal_type=self.getPortalVariationTypeList())
except:
other_variations = []
other_variations = map(lambda x: x.getObject(), other_variations) other_variations = map(lambda x: x.getObject(), other_variations)
other_variations = filter(lambda x: x is not None, other_variations) other_variations = filter(lambda x: x is not None, other_variations)
...@@ -511,3 +507,25 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -511,3 +507,25 @@ class Resource(XMLMatrix, CoreResource, Variated):
p.setMembershipCriterionCategoryList(('resource/%s' % self.getRelativeUrl(),)) p.setMembershipCriterionCategoryList(('resource/%s' % self.getRelativeUrl(),))
return p return p
security.declareProtected(Permissions.AccessContentsInformation, 'getPrice')
def getPrice(self, context=None, REQUEST=None, **kw):
"""
"""
tmp_context = self.asContext(context=context, REQUEST=REQUEST, **kw)
domain_tool = getToolByName(self,'portal_domains')
mapped_value = domain_tool.generateMappedValue(tmp_context,**kw)
base_price = mapped_value.getBasePrice()
unit_base_price = None
if base_price in [None,'']:
base_price = self.getBasePrice()
if base_price is not None:
priced_quantity = self.getPricedQuantity()
unit_base_price = base_price / priced_quantity
else:
priced_quantity = mapped_value.getPricedQuantity()
unit_base_price = base_price / priced_quantity
return unit_base_price
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