You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[FIX] sale_loyalty: keep track of coupon changes on confirmed orders
Versions
--------
- 17.0+
Steps
-----
1. Have a coupon program;
2. add a 10% discount on order reward for 1 point;
3. add a 50% discount on order reward for 5 points;
4. generate a coupon with 10 points;
5. use coupon code on a confirmed order;
6. select 10% discount reward;
7. change to a 50% discount reward;
8. check coupon point total.
Issue
-----
Even though the 5 point reward was used, only 4 out of 10 points remain.
Cause
-----
When updating the reward line of a confirmed order, it keeps track of
point cost changes before & after a write. Its purpose is to restore
back the point difference on the coupon record.
The issue is that while point changes are stored, coupon changes are
not. When updating reward lines, `_reset_loyalty` is used, which removes
the `coupon_id` from the lines. As a consequence, attempting to restore
the point difference on `line.coupon_id` after an update, it writes to
an empty record.
Solution
--------
Store both coupons & their used points before write. After write,
restore the previous points to the previous coupon, and subtract the
current point cost from the current coupon. This way, any combination of
coupon/point changes should have the points updated as expected.
opw-4910922
closesodoo#231120
X-original-commit: ee7abc9
Signed-off-by: Levi Siuzdak <[email protected]>
Signed-off-by: Valeriya Chuprina (vchu) <[email protected]>
0 commit comments