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):
}
if mapped_value is None:
return price_parameter_dict
for price_parameter_name in price_parameter_dict.keys():
price_parameter_value = \
mapped_value.getProperty(price_parameter_name,
d=price_parameter_dict[price_parameter_name])
if price_parameter_value not in [None, [], '']:
try:
price_parameter_dict[price_parameter_name].extend(
price_parameter_value)
except AttributeError:
if price_parameter_dict[price_parameter_name] is None:
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]
for mapped_value_property in mapped_value.getMappedValuePropertyList():
value = getattr(mapped_value, mapped_value_property)
try:
price_parameter_dict[mapped_value_property].extend(value)
except AttributeError:
price_parameter_dict[mapped_value_property] = max(value) \
if mapped_value_property == 'exclusive_discount_ratio' \
else value[0]
except KeyError:
price_parameter_dict[mapped_value_property] = value
return price_parameter_dict
security.declareProtected(Permissions.AccessContentsInformation,
......
......@@ -353,7 +353,9 @@ class DomainTool(BaseTool):
if explanation_only:
return dict(explanation_dict)
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)
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