From 7670c6c80a0717bc003655febbccf255cd38136b Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 27 Jun 2019 11:47:10 +0000 Subject: [PATCH] [FIX] pos_discount: change customer - Enable general discounts for POS - Create a POS session - Add a product - Create a general discount of 10% - Change the customer The discount is reset to the product price. When changing the customer, the prices are reset: https://github.com/odoo/odoo/blob/3b1699e02d4483913159681bf7e10839e6493244/addons/point_of_sale/static/src/js/screens.js#L1251 In the case of a global discount, the price is therefore reset to the product price in: https://github.com/odoo/odoo/blob/3b1699e02d4483913159681bf7e10839e6493244/addons/point_of_sale/static/src/js/models.js#L2304 To avoid this, we set the price as manually set. Conceptually, this is indeed the case since we manually chose the percentage, therefore the price. opw-2009761 closes odoo/odoo#34416 Signed-off-by: Nicolas Martinelli (nim) --- addons/pos_discount/static/src/js/discount.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/pos_discount/static/src/js/discount.js b/addons/pos_discount/static/src/js/discount.js index 87b97f88e16..fc41e55bc05 100644 --- a/addons/pos_discount/static/src/js/discount.js +++ b/addons/pos_discount/static/src/js/discount.js @@ -42,10 +42,16 @@ var DiscountButton = screens.ActionButtonWidget.extend({ } // Add discount + // We add the price as manually set to avoid recomputation when changing customer. var discount = - pc / 100.0 * order.get_total_with_tax(); if( discount < 0 ){ - order.add_product(product, { price: discount }); + order.add_product(product, { + price: discount, + extras: { + price_manually_set: true, + }, + }); } }, });