[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
This commit is contained in:
Joseph Caburnay
2023-10-27 13:02:17 +00:00
parent 29757d1079
commit 7510441cc3
@@ -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) {