From 123b705677358675f1db0dd312fcc419fcd740e1 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Tue, 23 Nov 2021 10:33:46 +0000 Subject: [PATCH] [FIX] pos_discount: pos app is stuck when changing the discount To reproduce: 1. Install pos_discount and pos_coupon. 2. Start a session and add item to the order. 3. Add global discount. 4. Change global discount. Stuck. This is because in some modules, get_orderlines is overridden. Instead of returning the original object containing the orderlines, it returns a different array instance containing the lines. This is the reason the while loop is stuck. With this change, whether get_orderlines return the container or a copy, we are sure that it won't be stuck in the for loop. closes odoo/odoo#81011 Task-id: 2697861 X-original-commit: 6d78748794a2db3f324312fc773f7a48fd0ffba4 Signed-off-by: Masereel Pierre Signed-off-by: Joseph Caburnay (jcb) --- addons/pos_discount/static/src/js/DiscountButton.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/pos_discount/static/src/js/DiscountButton.js b/addons/pos_discount/static/src/js/DiscountButton.js index e45f29f0294..5b147094b78 100644 --- a/addons/pos_discount/static/src/js/DiscountButton.js +++ b/addons/pos_discount/static/src/js/DiscountButton.js @@ -37,12 +37,9 @@ odoo.define('pos_discount.DiscountButton', function(require) { } // Remove existing discounts - var i = 0; - while ( i < lines.length ) { - if (lines[i].get_product() === product) { - order.remove_orderline(lines[i]); - } else { - i++; + for (const line of lines) { + if (line.get_product() === product) { + order.remove_orderline(line); } }