[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 <pim@odoo.com> Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user