From bccf88ae2df50909992a1d668e020a19b2f57aea Mon Sep 17 00:00:00 2001 From: MerlinGuillaume Date: Fri, 17 Jun 2022 09:15:53 +0000 Subject: [PATCH] [FIX] pos_coupon: apply discounts on lines' discounted amount Order discount do not take into account the discount on order lines so the discount amount will be wrong Steps to reproduce: 1. Install Point of Sale 2. Go to Settings > Point of Sale > Pricing and enable Coupons & Promotions 3. Go to Point of Sale > Products > Promotion Programs and edit program 'Code for 10% on orders' 4. Change the Promo Code Usage to 'Automatically Applied' 5. Open a new session in Point of Sale 'Shop' 6. Add a product (e.g. Acoustic Bloc Screens, the discount is applied with value 29.50$) 7. Apply a discount of 20% on the product, the discount value doesn't change (it should be 23.60$) Solution: When computing the amount to discount, take into consideration the discount already applied on the order line opw-2883724 closes odoo/odoo#94791 X-original-commit: afb3e5516e43e831bec1fd6b6bc3aaa18fe3fde2 Signed-off-by: Guillaume Merlin (megu) --- addons/pos_loyalty/static/src/js/Loyalty.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/pos_loyalty/static/src/js/Loyalty.js b/addons/pos_loyalty/static/src/js/Loyalty.js index fb27357377c..8c4d9de6033 100644 --- a/addons/pos_loyalty/static/src/js/Loyalty.js +++ b/addons/pos_loyalty/static/src/js/Loyalty.js @@ -1028,7 +1028,7 @@ const PosLoyaltyOrder = (Order) => class PosLoyaltyOrder extends Order { if (!discountablePerTax[taxKey]) { discountablePerTax[taxKey] = 0; } - discountablePerTax[taxKey] += line.price * line.get_quantity(); + discountablePerTax[taxKey] += line.get_base_price(); } return {discountable, discountablePerTax}; } @@ -1164,7 +1164,7 @@ const PosLoyaltyOrder = (Order) => class PosLoyaltyOrder extends Order { if (!discountablePerTax[taxKey]) { discountablePerTax[taxKey] = 0; } - discountablePerTax[taxKey] += (line.price * line.get_quantity()) * (remainingAmountPerLine[line.cid] / line.get_price_with_tax()); + discountablePerTax[taxKey] += (line.get_base_price()) * (remainingAmountPerLine[line.cid] / line.get_price_with_tax()); } return {discountable, discountablePerTax}; }