Commit 342ef181 authored by Julien Muchembled's avatar Julien Muchembled

Make Resource.getPriceParameterDict return extra mapped values

For example, Sale Supply Lines/Cells can be customized to return values for
the caller of Movement.getPriceCalculationOperandDict
parent 68ec6bda
...@@ -697,22 +697,16 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin): ...@@ -697,22 +697,16 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin):
} }
if mapped_value is None: if mapped_value is None:
return price_parameter_dict return price_parameter_dict
for price_parameter_name in price_parameter_dict.keys(): for mapped_value_property in mapped_value.getMappedValuePropertyList():
price_parameter_value = \ value = getattr(mapped_value, mapped_value_property)
mapped_value.getProperty(price_parameter_name, try:
d=price_parameter_dict[price_parameter_name]) price_parameter_dict[mapped_value_property].extend(value)
if price_parameter_value not in [None, [], '']: except AttributeError:
try: price_parameter_dict[mapped_value_property] = max(value) \
price_parameter_dict[price_parameter_name].extend( if mapped_value_property == 'exclusive_discount_ratio' \
price_parameter_value) else value[0]
except AttributeError: except KeyError:
if price_parameter_dict[price_parameter_name] is None: price_parameter_dict[mapped_value_property] = value
if price_parameter_name == 'exclusive_discount_ratio':
price_parameter_dict[price_parameter_name] = \
max(price_parameter_value)
else:
price_parameter_dict[price_parameter_name] = \
price_parameter_value[0]
return price_parameter_dict return price_parameter_dict
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
......
...@@ -353,7 +353,9 @@ class DomainTool(BaseTool): ...@@ -353,7 +353,9 @@ class DomainTool(BaseTool):
if explanation_only: if explanation_only:
return dict(explanation_dict) return dict(explanation_dict)
mapped_value = newTempSupplyCell(self.getPortalObject(), mapped_value = newTempSupplyCell(self.getPortalObject(),
'new_mapped_value') 'multivalued_mapped_value')
mapped_value._setMappedValuePropertyList(
mapped_value_property_dict.keys())
mapped_value.__dict__.update(mapped_value_property_dict) mapped_value.__dict__.update(mapped_value_property_dict)
return mapped_value return mapped_value
......
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