Commit aa07942a authored by Nicolas Delaby's avatar Nicolas Delaby

Add uid in criterion keys to avoid fetching current object.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33945 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8124e929
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002, 2005 Nexedi SARL and Contributors. All Rights Reserved.
......@@ -31,6 +32,7 @@
from PropertyExistence import PropertyExistence
from Products.CMFCore.Expression import Expression
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery
class AttributeUnicity(PropertyExistence):
"""
......@@ -67,7 +69,10 @@ class AttributeUnicity(PropertyExistence):
from Products.ERP5Type.Utils import createExpressionContext
econtext = createExpressionContext(obj)
criterion_dict = expression(econtext)
result = obj.portal_catalog.countResults(**criterion_dict)[0][0]
# Add uid in criterion keys to avoid fetching current object.
criterion_dict['query'] = NegatedQuery(Query(uid=obj.getUid()))
portal = obj.portal_catalog.getPortalObject()
result = portal.portal_catalog.countResults(**criterion_dict)[0][0]
if result >= 1:
mapping['value'] = criterion_dict.get(attribute_name)
message_id = 'message_invalid_attribute_unicity'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment