Commit fd8688f6 authored by Romain Courteaud's avatar Romain Courteaud

Add method getUnitBasePrice.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2644 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 29c6f438
......@@ -89,6 +89,36 @@ class SupplyLineMixin(ExtensionClass.Base):
return XMLMatrix.newCell(self, *kw, **kwd)
security.declareProtected(Permissions.AccessContentsInformation, 'getUnitBasePrice')
def getUnitBasePrice(self, context=None, REQUEST=None, **kw):
"""
"""
tmp_context = self.asContext(context=context, REQUEST=REQUEST, **kw)
base_id = 'path'
# get Quantity
base_price = None
if tmp_context != None:
# We will browse the mapped values and determine which apply
cell_key_list = self.getCellKeyList( base_id = base_id )
for key in cell_key_list:
if self.hasCell(base_id=base_id, *key):
mapped_value = self.getCell(base_id=base_id, *key)
if mapped_value.test(tmp_context):
if 'price' in mapped_value.getMappedValuePropertyList():
base_price = mapped_value.getProperty('price')
if base_price in [None,'']:
base_price = self.getBasePrice()
priced_quantity = self.getPricedQuantity()
try:
unit_base_price = base_price / priced_quantity
except:
unit_base_price = None
return unit_base_price
class SupplyLine(DeliveryLine, Path):
"""
......@@ -284,5 +314,6 @@ Une ligne tarifaire."""
p.setTitle('%s <= quantity < %s' % (repr(value[i]),repr(value[i+1])))
self._setVariationCategoryList(self.getVariationCategoryList())
from Products.ERP5Type.Utils import monkeyPatch
monkeyPatch(SupplyLineMixin,SupplyLine)
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