Skip to content

Commit

Permalink
[FIX] sale_loyalty_delivery: fix reward for multiple delivery lines
Browse files Browse the repository at this point in the history
The method `_get_reward_values_free_shipping` assumes there is only one
delivery line per sale order. But it is not always the case. This commit
therefore makes sure the method does not raise an error in case of
multiple lines by taking into account only the first delivery line.

Fixes #136395

closes #159584

Signed-off-by: Vallaeys Valentin (vava) <vava@odoo.com>
  • Loading branch information
vava-odoo committed Mar 28, 2024
1 parent 726d973 commit 2ce67da
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/sale_loyalty_delivery/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _get_not_rewarded_order_lines(self):
return order_line.filtered(lambda line: not line.is_delivery)

def _get_reward_values_free_shipping(self, reward, coupon, **kwargs):
delivery_line = self.order_line.filtered(lambda l: l.is_delivery)
delivery_line = self.order_line.filtered(lambda l: l.is_delivery)[:1]
taxes = delivery_line.product_id.taxes_id.filtered(lambda t: t.company_id.id == self.company_id.id)
taxes = self.fiscal_position_id.map_tax(taxes)
max_discount = reward.discount_max_amount or float('inf')
Expand Down

0 comments on commit 2ce67da

Please sign in to comment.