[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) <thle@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<template id="sale_purchased_gift_card">
|
||||
<t t-set="gift_cards" t-value="order.coupon_point_ids.filtered(lambda pe: pe.coupon_id.program_id.program_type == 'gift_card').coupon_id"/>
|
||||
<div class="card mt-3 " t-if="gift_cards">
|
||||
<div class="card mt-3 " t-if="gift_cards and order.state in ('sale', 'done')">
|
||||
<div class="card-body">
|
||||
<span t-if="not hide_intro">You will find below your gift cards code. An email has been sent with it. You can use it starting right now.</span>
|
||||
<table class="table text-center table-borderless">
|
||||
|
||||
Reference in New Issue
Block a user