From ad48cd1de84c67f6edcdbb32528dde83cf3e146d Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Fri, 22 Apr 2022 08:02:14 +0000 Subject: [PATCH] [FIX] sale_loyalty: fix pricing on free products Previously free products from loyalty programs were given as the product with a price_unit of 0, it will now have the complete price but with a 100% discount instead. closes odoo/odoo#89691 X-original-commit: 39202e71b0df2f5f6d8bfec54e21b4ae4d899b7f Signed-off-by: Yannick Tivisse (yti) Signed-off-by: William Braeckman (wbr) --- addons/sale_loyalty/models/sale_order.py | 2 +- addons/sale_loyalty/models/sale_order_line.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale_loyalty/models/sale_order.py b/addons/sale_loyalty/models/sale_order.py index 37c29d032f5..c9118105c69 100644 --- a/addons/sale_loyalty/models/sale_order.py +++ b/addons/sale_loyalty/models/sale_order.py @@ -139,7 +139,7 @@ class SaleOrder(models.Model): return [{ 'name': _("Free Product - %(product)s", product=product.name), 'product_id': product.id, - 'price_unit': 0, + 'discount': 100, 'product_uom_qty': reward.reward_product_qty * claimable_count, 'reward_id': reward.id, 'coupon_id': coupon.id, diff --git a/addons/sale_loyalty/models/sale_order_line.py b/addons/sale_loyalty/models/sale_order_line.py index 638beff879b..c0b97411d2d 100644 --- a/addons/sale_loyalty/models/sale_order_line.py +++ b/addons/sale_loyalty/models/sale_order_line.py @@ -40,7 +40,7 @@ class SaleOrderLine(models.Model): def _get_display_price(self): # A product created from a promotion does not have a list_price. # The price_unit of a reward order line is computed by the promotion, so it can be used directly - if self.is_reward_line: + if self.is_reward_line and self.reward_id.reward_type != 'product': return self.price_unit return super()._get_display_price()