-
- Downloads
[FIX] sale_coupon: lost program information on line deletion
Versions: --------- (- 14.0) - 15.0 - saas-15.2 Steps to reproduce: ------------------- 1) Create two products: - one without tax (A) - one with tax (B) 2) Create a promotion program which applies a discount to the sale order and is triggered by a code 3) Add these two products to the ecommerce cart 4) Apply the promotion program 5) Remove the product with a tax (B) 6) Re-apply the promotion program Issue: ------ The promotion program is applied twice. The mechanism can be repeated to apply the promotion program as many times as we want. Cause: ------ When the product with tax is removed from the order (step 5), a call to `_cart_update` > `recompute_coupon_lines` > `_update_existing_reward_lines`, which will: 1) remove the reward line corresponding to the removed line which will 1a) remove the program from the order 1b) remove all reward lines from this program from the order 2) recreate the other reward lines of the program that should be kept In our steps, the reward line representing the discount on product A This results in a sale order holding the expected reward of the program, but without being linked to this program anymore. Solution: --------- If for a given program, some lines are kept and some removed, we have to make sure the program stays linked to the order, making sure it cannot be applied multiple times. opw-3267359 closes odoo/odoo#128542 Signed-off-by:Victor Feyens (vfe) <vfe@odoo.com> Co-authored-by:
Victor Feyens <vfe@odoo.com>
Showing
- addons/sale_coupon/models/sale_order.py 25 additions, 1 deletionaddons/sale_coupon/models/sale_order.py
- addons/sale_coupon/tests/test_program_with_code_operations.py 65 additions, 0 deletions...ns/sale_coupon/tests/test_program_with_code_operations.py
- addons/sale_coupon/tests/test_program_without_code_operations.py 62 additions, 0 deletions...sale_coupon/tests/test_program_without_code_operations.py
Please register or sign in to comment