Commit f201eada authored by Julien Muchembled's avatar Julien Muchembled

Fix TestTransformation.test_01_getAggregatedAmountListWithVariatedProperty

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@39526 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bd7e7497
...@@ -39,6 +39,10 @@ _MARKER = [] ...@@ -39,6 +39,10 @@ _MARKER = []
class MappedValue(Predicate): class MappedValue(Predicate):
""" """
A MappedValue allows to associate a value to a predicate A MappedValue allows to associate a value to a predicate
XXX Why do we redefine xxxProperty methods ?
When a property is defined by a property sheet with a specific storage_id,
they break accessors of this property when a value is mapped to it.
""" """
meta_type = 'ERP5 Mapped Value' meta_type = 'ERP5 Mapped Value'
portal_type = 'Mapped Value' portal_type = 'Mapped Value'
......
...@@ -63,7 +63,18 @@ class TransformedResource(AmountGeneratorLine): ...@@ -63,7 +63,18 @@ class TransformedResource(AmountGeneratorLine):
# Provide default mapped value properties and categories if # Provide default mapped value properties and categories if
# not defined # not defined
def getMappedValuePropertyList(self): def getMappedValuePropertyList(self):
return self._baseGetMappedValuePropertyList() or ('quantity',) result = self._baseGetMappedValuePropertyList()
if not result:
result = ['quantity']
# Take into account variation_property_list for each variation
# for which hasProperty is true...
# FIXME: Why the resource and not the model line itself ? Or both ??
resource = self.getDefaultResourceValue()
if resource is not None:
# XXX Using getattr directly is a hack. See MappedValue.__doc__
result.extend(key for key in resource.getVariationPropertyList()
if getattr(self, key, self) is not self)
return result
def getMappedValueBaseCategoryList(self): def getMappedValueBaseCategoryList(self):
result = self._baseGetMappedValueBaseCategoryList() result = self._baseGetMappedValueBaseCategoryList()
......
...@@ -134,8 +134,13 @@ class TestTransformation(TestTransformationMixin, BaseTestUnitConversion): ...@@ -134,8 +134,13 @@ class TestTransformation(TestTransformationMixin, BaseTestUnitConversion):
""" """
# Only for testing purpose, use a property sheet that has nothing to # Only for testing purpose, use a property sheet that has nothing to
# do with component. It would have been possible to create a new # do with component. It would have been possible to create a new
# property sheet for this test # property sheet for this test.
# When one do that, the property sheet should be added to many other types
# like movements, order lines and so on.
self._addPropertySheet('Amount', 'Bug')
self._addPropertySheet(self.transformed_resource_portal_type, 'Bug') self._addPropertySheet(self.transformed_resource_portal_type, 'Bug')
# XXX 'tested' works here because 'storage_id' does not differ
# (see also MappedValue.__doc__)
variation_property_list = ['tested'] variation_property_list = ['tested']
transformation = self.createTransformation() transformation = self.createTransformation()
......
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