Files
odoo_source/addons
Ethan Vincent a11bca1810 [FIX] sale_loyalty: skip paid calc if ewallet type
**Current behavior:**
Creating an ewallet loyalty program and removing the default
value for `trigger_product_ids` without adding another in its
place will result in any ewallet created using that program to
not have its balance deducted after being used in a sale order.

**Expected behavior:**
The default product should not be required here, nor should any
product, seeing as there is no `required` constraint on this
field nor any related ones.

**Steps to reproduce:**
1. Create an ewallet loyalty program and remove the Top-up
     ewallet product

2. Create an ewallet, give it some balance, and use it in an
     order

3. Check the balance of the wallet to see the erroneous behavior

**Cause of the issue:**
In the _program_check_compute_points() method of `sale.order` in
`sale_loyalty`, the conditional block:

`if not products_per_rule.get(rule):
    continue`

will normally prevent rules belonging to ewallet program types
from going further in the method because they have the default
ewallet top-up product in their domain. When the continue is not
reached, they will reach this line:

`amount_paid = sum(max(0, line.price_total) for
    line in order_lines if line.product_id in rule_products)`

which will end up offsetting the actual subtraction of a SOLs
`points_cost` from an ewallet `loyalty.card`'s balance.

**Fix:**
Add another check prior to the calculation of order points which
prevents ewallet coupons without any top-up products from
reaching the problematic code. If an ewallet program doesn't
have any `trigger_product_ids`, it shouldn't ever need to
perform such calculations.

opw-3756134

closes odoo/odoo#159957

X-original-commit: 695b3a687a3d160451339a675aab8986682389eb
Signed-off-by: Vincent Ethan <etvi@odoo.com>
2024-04-05 07:20:46 +00:00
..
2024-04-03 16:27:10 +00:00
2024-04-03 16:27:10 +00:00
2024-03-08 11:17:48 +00:00
2024-02-22 09:06:12 +00:00
2024-01-26 09:13:03 +00:00
2024-03-15 17:30:00 +00:00
2024-04-03 16:27:10 +00:00
2024-04-03 16:27:10 +00:00
2024-04-04 18:39:19 +00:00
2024-04-03 16:27:10 +00:00
2024-04-04 09:52:46 +00:00
2024-04-03 16:27:10 +00:00