Commit a96fa2a8 authored by Julien Muchembled's avatar Julien Muchembled

Fix Trade Model Solver that wrongly skipped some TM related simulation movements

This fixes a regression in recent commit 6e758ade

The following line:

  simulation_movement_list = delivery_dict.get(movement) or \
    movement.getDeliveryRelatedValueList()

didn't work because the loop that fills delivery_dict does not necessarily
find all related simulation movements for every key.

New code is a little complicated because it tries to not call
getDeliveryRelatedValueList() when 'movement' is not related to trade model.
parent 72ec5cfd
......@@ -81,12 +81,19 @@ class TradeModelSolver(AcceptSolver):
for delivery in set(movement.getRootDeliveryValue()
for movement in delivery_dict):
for movement in delivery.getMovementList():
simulation_movement_list = delivery_dict.get(movement) or \
movement.getDeliveryRelatedValueList()
applied_rule = simulation_movement_list[0].getParentValue()
movement_list = delivery_dict.get(movement)
# hard coded reference name
if applied_rule.getSpecialiseReference() == 'default_trade_model_rule':
trade_model_related_movement_dict[movement] = simulation_movement_list
if movement_list:
rule = movement_list[0].getParentValue().getSpecialiseReference()
if rule != 'default_trade_model_rule':
continue
movement_list = movement.getDeliveryRelatedValueList()
else:
movement_list = movement.getDeliveryRelatedValueList()
rule = movement_list[0].getParentValue().getSpecialiseReference()
if rule != 'default_trade_model_rule':
continue
trade_model_related_movement_dict[movement] = movement_list
with self.defaultActivateParameterDict(activate_kw, True):
# Second, apply changes on invoice lines to simulation movements,
......
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