From eecfbbe12a7207568d037e8828dfa1c338ce2c7b Mon Sep 17 00:00:00 2001
From: Kazuhiko SHIOZAKI <kazuhiko@nexedi.com>
Date: Fri, 15 Dec 2017 08:33:34 +0000
Subject: [PATCH] erp5_pdm: respect existing predicate in
 TransformationOptionalResource_asPredicate.

---
 .../TransformationOptionalResource_asPredicate.py  | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/bt5/erp5_pdm/SkinTemplateItem/portal_skins/erp5_pdm/TransformationOptionalResource_asPredicate.py b/bt5/erp5_pdm/SkinTemplateItem/portal_skins/erp5_pdm/TransformationOptionalResource_asPredicate.py
index 059ad0b4f7..1e776fdaed 100644
--- a/bt5/erp5_pdm/SkinTemplateItem/portal_skins/erp5_pdm/TransformationOptionalResource_asPredicate.py
+++ b/bt5/erp5_pdm/SkinTemplateItem/portal_skins/erp5_pdm/TransformationOptionalResource_asPredicate.py
@@ -1,9 +1,11 @@
-option_category = context.getOptionList()
-option_base_category = []
-if len(option_category) > 0:
-  option_base_category = [option_category[0].split('/')[0]]
+membership_criterion_category_list = context.getMembershipCriterionCategoryList()
+membership_criterion_base_category_list = context.getMembershipCriterionBaseCategoryList()
+
+for option in context.getOptionList():
+  membership_criterion_category_list.append(option)
+  membership_criterion_base_category_list.append(option.split('/')[0])
 
 new_context = context.asContext(
-    membership_criterion_category=option_category,
-    membership_criterion_base_category=option_base_category)
+    membership_criterion_category=tuple(set(membership_criterion_category_list)),
+    membership_criterion_base_category=tuple(set(membership_criterion_base_category_list)))
 return new_context
-- 
2.30.9