diff --git a/product/ERP5/Document/Person.py b/product/ERP5/Document/Person.py index f629510fd1e368beb29e87b1263a63a97e4763e7..8005c2cb92502ef013fbb1dec15e18d787718164 100755 --- a/product/ERP5/Document/Person.py +++ b/product/ERP5/Document/Person.py @@ -141,3 +141,19 @@ class Person(Entity, Node, XMLObject): """ self._setLastName(value) self.reindexObject() + + security.declareProtected('Manage users', 'setReference') + def setReference(self, value): + """ + Set the user id. This method is defined explicitly, because: + + - we want to apply a different permission + + - we want to prevent duplicated user ids + """ + if value: + user_list = self.acl_users.searchUsers(id = value, exact_match = True) + if len(user_list) > 0: + raise RuntimeError, 'user id %s already exist' % (value,) + self._setReference(value) + self.reindexObject()