From 7510441cc32601676587de0338707d28a71ecf1b Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Tue, 17 Oct 2023 17:25:37 +0200 Subject: [PATCH] [FIX] pos_self_order: avoid unnecessary rpc when changing quantity When changing quantity of a menu order line (from combo product), multiple (number of components + 1) rpcs are made. It makes sense that when incrementing a menu order line, the components are also incremented. We, however, make the rpc whenever one of the line's quantity is incremented. This commit extracts the incrementer, and we only make the rpc when the incrementer method is done incrementing all the components. Part-of: odoo/odoo#139915 --- .../static/src/app/pages/cart_page/cart_page.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/pos_self_order/static/src/app/pages/cart_page/cart_page.js b/addons/pos_self_order/static/src/app/pages/cart_page/cart_page.js index 11e2698d421..bf8d8f2ce4f 100644 --- a/addons/pos_self_order/static/src/app/pages/cart_page/cart_page.js +++ b/addons/pos_self_order/static/src/app/pages/cart_page/cart_page.js @@ -152,7 +152,7 @@ export class CartPage extends Component { await this.selfOrder.getPricesFromServer(); } - async changeQuantity(line, increase) { + async _changeQuantity(line, increase) { if (!increase && !this.canChangeQuantity(line)) { return; } @@ -164,11 +164,14 @@ export class CartPage extends Component { increase ? line.qty++ : line.qty--; for (const cline of this.selfOrder.currentOrder.lines) { if (cline.combo_parent_uuid === line.uuid) { - this.changeQuantity(cline, increase); + this._changeQuantity(cline, increase); } } + } + + async changeQuantity(line, increase) { + await this._changeQuantity(line, increase); await this.selfOrder.getPricesFromServer(); - return; } clickOnLine(line) {