From eade8e70bda0a3c45be7c7f35eb74a5e5a5745f7 Mon Sep 17 00:00:00 2001
From: Yoshinori Okuji <yo@nexedi.com>
Date: Sat, 22 May 2010 00:40:35 +0000
Subject: [PATCH] Add support of passing supply path types explicitly to
 getPriceParameterDict. This is useful to filter out, for example, Purchase
 Supply Paths when the context is a Sale Order.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35541 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/Resource.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/product/ERP5/Document/Resource.py b/product/ERP5/Document/Resource.py
index 4cb6f035be..612cbc6179 100644
--- a/product/ERP5/Document/Resource.py
+++ b/product/ERP5/Document/Resource.py
@@ -660,7 +660,8 @@ class Resource(XMLMatrix, Variated):
 
     security.declareProtected(Permissions.AccessContentsInformation, 
                               'getPriceParameterDict')
-    def getPriceParameterDict(self, context=None, REQUEST=None, **kw):
+    def getPriceParameterDict(self, context=None, REQUEST=None,
+                              supply_path_type=None, **kw):
       """
       Get all pricing parameters from Predicate.
       """
@@ -679,7 +680,12 @@ class Resource(XMLMatrix, Variated):
       # Generate the predicate mapped value
       # to get some price values.
       domain_tool = getToolByName(self,'portal_domains')
-      portal_type_list = self.getPortalSupplyPathTypeList()
+      if supply_path_type is None:
+        portal_type_list = self.getPortalSupplyPathTypeList()
+      elif isinstance(supply_path_type, (list, tuple)):
+        portal_type_list = supply_path_type
+      else:
+        portal_type_list = (supply_path_type,)
 
       # Generate the fake context
       tmp_context = self.asContext(context=context, 
-- 
2.30.9