From 747b60e2c5f1f9db27c81d9bb372042db8caa7c8 Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Tue, 21 Feb 2023 13:49:20 +0000 Subject: [PATCH] [FIX] sale_loyalty: correct display coupon points Steps to reproduce: - install website_sale and website_sale_loyalty; - activate Payment Providers Demo and Wire Transfer; - put them in 'test mode'; - go to ecommerce; - add a gift card; - process the checkout. Issue: Depending on the configuration of the payment acquirer used, sometimes the amount displayed is doubled (in the display of the gift card amount after the payment process in brackets). - Demo in test mode: amount will be doubled - Wire Transfer in test mode: amount will not be doubled Remark: The amounts are correct in the backend. Cause: Sometimes the `action_confirm` function is used and sometimes it is not. When you enter it, the points of the coupon are already set. Therefore, we add the amount again in the `_get_real_points_for_coupon`. Solution: Display the information of the gift card only when the sale order is validated. Therefore, there is no need to bypass (with `post_confirm`) to add the points that will be valid when the sale order is confirmed. Because with the display correction, we won't see the points. opw-3166164 closes odoo/odoo#120227 X-original-commit: b3322ecc020e027c1b71ec3a222b8c2e5d0ee97e Signed-off-by: Lefebvre Thomas (thle) --- addons/sale_loyalty/models/sale_order.py | 2 +- addons/sale_loyalty/views/sale_portal_templates.xml | 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 48f1b5926bb..53ffaf84908 100644 --- a/addons/sale_loyalty/models/sale_order.py +++ b/addons/sale_loyalty/models/sale_order.py @@ -496,7 +496,7 @@ class SaleOrder(models.Model): """ self.ensure_one() points = coupon.points - if (coupon.program_id.applies_on != 'future' and self.state not in ('sale', 'done')) or post_confirm: + if coupon.program_id.applies_on != 'future' and self.state not in ('sale', 'done'): # Points that will be given by the order upon confirming the order points += self.coupon_point_ids.filtered(lambda p: p.coupon_id == coupon).points # Points already used by rewards diff --git a/addons/sale_loyalty/views/sale_portal_templates.xml b/addons/sale_loyalty/views/sale_portal_templates.xml index a8e901b9250..3a323796b13 100644 --- a/addons/sale_loyalty/views/sale_portal_templates.xml +++ b/addons/sale_loyalty/views/sale_portal_templates.xml @@ -20,7 +20,7 @@