diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml index 83f18f1f9e536ccfa665b4063159c7d15a9c8138..3882d1c66720e919f5501aaeeb9d1c91839ec646 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml @@ -85,7 +85,7 @@ for item in mixed_list:\n if item_list == [[\'\', \'\']]:\n for fallback_category in base_category.getFallbackBaseCategoryList():\n fallback_category = ctool.restrictedTraverse(fallback_category, None)\n - if fallback_category:\n + if fallback_category is not None and fallback_category.objectIds():\n item_list = [(\'%s/%s\' % (item, x[0]), \'%s/%s\' % (item, x[1])) for x in\n fallback_category.getCategoryChildCompactLogicalPathItemList(base=1)]\n break\n diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index 4e66132b50032ef4b80cd41c36efeb2353360c8c..fefb598af8c98e1a2953068d56df3a81f968074b 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -282 \ No newline at end of file +284 \ No newline at end of file diff --git a/product/ERP5/tests/testPredicate.py b/product/ERP5/tests/testPredicate.py index 8df4cd07f8460d89af575ee91a9201321ca862d1..eab099952d29fff3e9637a5e8a06b1df0e710389 100644 --- a/product/ERP5/tests/testPredicate.py +++ b/product/ERP5/tests/testPredicate.py @@ -378,6 +378,31 @@ class TestPredicates(ERP5TypeTestCase): self.assertEquals([True, False, True, False], calls) + def test_Predicate_getMembershipCriterionCategoryList(self): + # Predicate_getMembershipCriterionCategoryList is a script used to show the + # item list in Predicate_view/my_membership_criterion_category_list. + # When called on a predicate using a simple category (like region) as + # membership criterion base category, it will show for values the content + # of this category. + pred = self.createPredicate( + membership_criterion_base_category_list=['region'], ) + self.failUnless(('europe/western_europe', 'region/europe/western_europe') in + [tuple(x) for x in pred.Predicate_getMembershipCriterionCategoryList()], + pred.Predicate_getMembershipCriterionCategoryList(),) + + # If this category is empty, it will show values from fallback category, + # with the path they have when they are acquired + pred = self.createPredicate( + membership_criterion_base_category_list=['source_region'], ) + # note that the id of the actual base category is displayed in the first + # item too, for making it clear in the UI that it's the content of a + # category used for another base category. + self.failUnless(('source_region/europe/western_europe', + 'source_region/region/europe/western_europe') in + [tuple(x) for x in pred.Predicate_getMembershipCriterionCategoryList()], + pred.Predicate_getMembershipCriterionCategoryList(),) + + def test_PredicateFusion(self, quiet=QUIET, run=RUN_ALL_TESTS): """Test simple predicates fusion. New predicate act as a logical AND between predicates