equal
deleted
inserted
replaced
161 |
161 |
162 def __call__(self): |
162 def __call__(self): |
163 entity = self.entity |
163 entity = self.entity |
164 eschema = entity.e_schema |
164 eschema = entity.e_schema |
165 for attr in entity.edited_attributes: |
165 for attr in entity.edited_attributes: |
166 val = entity[attr] |
|
167 if val is None: |
|
168 continue |
|
169 if eschema.subject_relation(attr).is_final() and \ |
166 if eschema.subject_relation(attr).is_final() and \ |
170 eschema.has_unique_values(attr): |
167 eschema.has_unique_values(attr): |
|
168 val = entity[attr] |
|
169 if val is None: |
|
170 continue |
171 rql = '%s X WHERE X %s %%(val)s' % (entity.e_schema, attr) |
171 rql = '%s X WHERE X %s %%(val)s' % (entity.e_schema, attr) |
172 rset = self._cw.unsafe_execute(rql, {'val': val}) |
172 rset = self._cw.unsafe_execute(rql, {'val': val}) |
173 if rset and rset[0][0] != entity.eid: |
173 if rset and rset[0][0] != entity.eid: |
174 msg = self._cw._('the value "%s" is already used, use another one') |
174 msg = self._cw._('the value "%s" is already used, use another one') |
175 raise ValidationError(entity.eid, {attr: msg % val}) |
175 raise ValidationError(entity.eid, {attr: msg % val}) |