feat: add debounced auto-sync to pending orders on note updates in POS restaurant mode
This commit is contained in:
parent
f205e94c2b
commit
2f1e9d869a
@ -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",
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user