diff --git a/product/ERP5Type/Constraint/PropertyTypeValidity.py b/product/ERP5Type/Constraint/PropertyTypeValidity.py index 0a6e3a03dc15c1d62b8e1d5d6257380ad6bf1479..c97557603ad3908260dccaba88470217e2fe2d8a 100644 --- a/product/ERP5Type/Constraint/PropertyTypeValidity.py +++ b/product/ERP5Type/Constraint/PropertyTypeValidity.py @@ -73,7 +73,8 @@ class PropertyTypeValidity(Constraint): " (Type cast failed with error ${type_cast_error})" message_incorrect_type_fixed = "Attribute ${attribute_name}"\ " should be of type ${expected_type} but is of type ${actual_type} (Fixed)" - message_value_modified = "Value of '${key}' was modified from '${old}' to '${new}'." + message_local_property_migrated = "Property ${property_id} was migrated from local properties." + message_local_property_modified = "Property ${property_id} was modified from ${old_value} to ${new_value}." def _checkConsistency(self, obj, fixit=0): """Check the object's consistency. @@ -96,6 +97,9 @@ class PropertyTypeValidity(Constraint): len([x for x in obj._propertyMap() if x['id'] == property_id]) > 1: obj._local_properties = tuple([x for x in obj._local_properties if x['id'] != property_id]) + error_list.append(self._generateError(obj, + self._getMessage('message_local_property_migrated'), dict( + property_id=property_id))) property_was_local = True if property_type in self._permissive_type_list: @@ -141,8 +145,8 @@ class PropertyTypeValidity(Constraint): oldvalue = getattr(obj, property_id, value) if oldvalue != value: error_list.append(self._generateError(obj, - self._getMessage('message_value_modified'), dict( - key=property_id, old=oldvalue, new=value))) + self._getMessage('message_local_property_modified'), dict( + property_id=property_id, old_value=oldvalue, new_value=value))) obj.setProperty(property_id, value) return error_list diff --git a/product/ERP5Type/tests/testConstraint.py b/product/ERP5Type/tests/testConstraint.py index 4917c136acd0d7f470979eec0cf96c962a1475db..ebba4084831393134445e9ecd8e1c85c06b81466 100644 --- a/product/ERP5Type/tests/testConstraint.py +++ b/product/ERP5Type/tests/testConstraint.py @@ -1215,7 +1215,8 @@ class TestConstraint(PropertySheetTestCase): portal_type="Standard Property", property_id="local_property", elementary_type="string") - constraint.fixConsistency(obj) + self.assertEqual(['Property local_property was migrated from local properties.'], + [str(q.getMessage()) for q in constraint.fixConsistency(obj)]) self.assertEquals((), obj._local_properties) self.assertEquals('1', obj.getLocalProperty()) obj.edit(local_property='something else') @@ -1237,7 +1238,8 @@ class TestConstraint(PropertySheetTestCase): portal_type="Standard Property", property_id="local_property", elementary_type="float") - constraint.fixConsistency(obj) + self.assertEqual(['Property local_property was migrated from local properties.'], + [str(q.getMessage()) for q in constraint.fixConsistency(obj)]) self.assertEquals((), obj._local_properties) self.assertEquals(1.234, obj.getLocalProperty()) obj.edit(local_property=3) @@ -1269,7 +1271,8 @@ class TestConstraint(PropertySheetTestCase): ti._setTypeAllowedContentTypeList(allowed_types + ['Organisation']) transaction.commit() try: - constraint.fixConsistency(obj) + self.assertEqual(['Property local_property was migrated from local properties.'], + [str(q.getMessage()) for q in constraint.fixConsistency(obj)]) self.assertEquals('foo', obj.getDefaultOrganisationTitle()) self.assertEquals('foo', obj.default_organisation.getTitle()) finally: @@ -1293,7 +1296,8 @@ class TestConstraint(PropertySheetTestCase): portal_type="Category Property", property_id="testing_category") # fix consistency - constraint.fixConsistency(obj) + self.assertEqual(['Property local_property was migrated from local properties.'], + [str(q.getMessage()) for q in constraint.fixConsistency(obj)]) # now we can use testing_category as any category accessor self.assertEquals(obj, obj.getTestingCategoryValue())