diff --git a/product/ERP5/Document/Predicate.py b/product/ERP5/Document/Predicate.py index 20cfbf22ca79d0ae41647a390abff42770c973ef..aac1d0c43721b7ca7b82e00f8fc1b8b13a0a1a2b 100644 --- a/product/ERP5/Document/Predicate.py +++ b/product/ERP5/Document/Predicate.py @@ -543,8 +543,21 @@ class Predicate(XMLObject): new_membership_criterion_base_category_list.append(base_category) new_criterion_property_list = list(self.getCriterionPropertyList()) - identity_criterion = getattr(self,'_identity_criterion',{}) - range_criterion = getattr(self,'_range_criterion',{}) + + # We need to build new criteria for asContext, and we should not + # modify the original, so we always make copies. Since the usage is + # temporary, use dicts instead of persistent mappings. + identity_criterion = getattr(self, '_identity_criterion', None) + if identity_criterion is None: + identity_criterion = {} + else: + identity_criterion = dict(identity_criterion) + range_criterion = getattr(self, '_range_criterion', None) + if range_criterion is None: + range_criterion = {} + else: + range_criterion = dict(range_criterion) + # Look at local properties and make it criterion properties for property in criterion_property_list: if property not in self.getCriterionPropertyList() \