From 2f1e9d869abb6d15475501d4d139322c0a433d4f Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Tue, 16 Jun 2026 16:39:18 +0700 Subject: [PATCH] feat: add debounced auto-sync to pending orders on note updates in POS restaurant mode --- .../app/screens/product_screen/notes_patch.js | 3 +++ static/src/app/services/pos_store_patch.js | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/static/src/app/screens/product_screen/notes_patch.js b/static/src/app/screens/product_screen/notes_patch.js index 7e07b7b..8539794 100644 --- a/static/src/app/screens/product_screen/notes_patch.js +++ b/static/src/app/screens/product_screen/notes_patch.js @@ -35,6 +35,7 @@ patch(NoteButton.prototype, { } else { this.setOrderlineNote(payload); } + this.pos.addPendingOrder([selectedOrderline.order_id.id]); } }); @@ -54,8 +55,10 @@ patch(InternalNoteButton.prototype, { const coloredNotes = payload ? this.reframeNotes(payload) : "[]"; if (selectedOrderline) { this.setChanges(selectedOrderline, coloredNotes); + this.pos.addPendingOrder([selectedOrderline.order_id.id]); } else { this.pos.getOrder().setInternalNote(coloredNotes); + this.pos.addPendingOrder([this.pos.getOrder().id]); } return { confirmed: typeof payload === "string", diff --git a/static/src/app/services/pos_store_patch.js b/static/src/app/services/pos_store_patch.js index f897a9d..06306f4 100644 --- a/static/src/app/services/pos_store_patch.js +++ b/static/src/app/services/pos_store_patch.js @@ -3,6 +3,7 @@ import { PosStore } from "@point_of_sale/app/services/pos_store"; import { patch } from "@web/core/utils/patch"; import { toRaw } from "@odoo/owl"; +import { debounce } from "@web/core/utils/timing"; patch(PosStore.prototype, { clearProductsCache() { @@ -18,6 +19,22 @@ patch(PosStore.prototype, { return await super.editProduct(...arguments); }, + addPendingOrder(orderIds, remove = false) { + const result = super.addPendingOrder(...arguments); + if (this.config.module_pos_restaurant && !remove) { + if (!this._autoSyncOnEditDebounced) { + this._autoSyncOnEditDebounced = debounce(() => { + const pending = this.getPendingOrder(); + if (pending.orderToUpdate.length > 0 || pending.orderToCreate.length > 0) { + this.syncAllOrdersDebounced(); + } + }, 1500); + } + this._autoSyncOnEditDebounced(); + } + return result; + }, + get productsToDisplay() { const searchWord = this.searchProductWord.trim(); const categoryId = this.selectedCategory?.id || 0;