diff --git a/product/ERP5/Document/MappedProperty.py b/product/ERP5/Document/MappedProperty.py index 1bd9bce9b9f5b2369a1001194d341448c074d870..3eb6630108a3b5ddb76fd745f3f2c071af64d4c3 100644 --- a/product/ERP5/Document/MappedProperty.py +++ b/product/ERP5/Document/MappedProperty.py @@ -64,3 +64,24 @@ class MappedProperty(XMLObject): return -1 * getProperty(mapped_property[1:]) else: return getProperty(mapped_property) + + security.declareProtected(Permissions.AccessContentsInformation, + 'setMappedProperty') + def setMappedProperty(self, document, property, value): + if property.endswith('_list'): + property = property[:-5] + setProperty = document.setPropertyList + else: + setProperty = document.setProperty + mapping_dict = {} + for x in self.getMappingPropertyList(): + from_property, to_property = [x.strip() for x in x.split('|')] + if to_property.startswith('-'): + mapping_dict[to_property[1:]] = '-%s' % from_property + else: + mapping_dict[to_property] = from_property + mapped_property = mapping_dict.get(property, property) + if mapped_property.startswith('-'): + return setProperty(-1 * value) + else: + return setProperty(value) diff --git a/product/ERP5/Document/SimulationMovement.py b/product/ERP5/Document/SimulationMovement.py index 28afbf9c595f7cb8fe649d7c47a3072afc79aca3..fa9ca5eae43857b6952994c465ef990f39e48830 100644 --- a/product/ERP5/Document/SimulationMovement.py +++ b/product/ERP5/Document/SimulationMovement.py @@ -618,3 +618,12 @@ class SimulationMovement(Movement, PropertyRecordableMixin): return mapping.getMappedProperty(self, property) else: return self.getProperty(property) + + security.declareProtected(Permissions.ModifyPortalContent, + 'setMappedProperty') + def setMappedProperty(self, property, value): + mapping = self.getPropertyMappingValue() + if mapping is not None: + return mapping.setMappedProperty(self, property, value) + else: + return self.setProperty(property, value)