From a8cc22a7458e4317ddc4d43a23cd7153be2657eb Mon Sep 17 00:00:00 2001 From: Fabien Morin <fabien@nexedi.com> Date: Mon, 24 May 2010 13:16:41 +0000 Subject: [PATCH] make possible to filter searhResults results (useful to filter by portal_types in listboxes for example) git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35565 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/Predicate.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/product/ERP5/Document/Predicate.py b/product/ERP5/Document/Predicate.py index ba68b5243b..b90b9a9312 100644 --- a/product/ERP5/Document/Predicate.py +++ b/product/ERP5/Document/Predicate.py @@ -235,7 +235,20 @@ class Predicate(XMLObject): 'range' : 'max' } else: - catalog_kw[criterion.property] = criterion.identity + # if a filter was passed as argument + if catalog_kw.has_key(criterion.property): + if isinstance(catalog_kw[criterion.property], (tuple, list)): + catalog_filter_set = set(catalog_kw[criterion.property]) + else: + catalog_filter_set = set([catalog_kw[criterion.property]]) + if isinstance(criterion.identity, (tuple, list)): + parameter_filter_set = set(criterion.identity) + else: + parameter_filter_set = set([criterion.identity]) + catalog_kw[criterion.property] = \ + list(catalog_filter_set.intersection(parameter_filter_set)) + else: + catalog_kw[criterion.property] = criterion.identity portal_catalog = getToolByName(self, 'portal_catalog') -- 2.30.9