From 3983b6a66d73c65028606e341cf74f6af354e4b2 Mon Sep 17 00:00:00 2001 From: Alaguraj0361 Date: Mon, 16 Feb 2026 16:17:11 +0530 Subject: [PATCH] Add Kitchen Display System (KDS) with real-time order status management and a dedicated Kanban view for order lines. --- addons/dine360_kds/models/pos_order_line.py | 14 ++++++++++++-- addons/dine360_kds/static/src/js/kds_backend.js | 17 +++++++++++++++-- addons/dine360_kds/static/src/js/pos_kds.js | 8 ++++++++ .../dine360_kds/views/pos_order_line_views.xml | 2 +- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/addons/dine360_kds/models/pos_order_line.py b/addons/dine360_kds/models/pos_order_line.py index 1dc6d94..a4f369d 100644 --- a/addons/dine360_kds/models/pos_order_line.py +++ b/addons/dine360_kds/models/pos_order_line.py @@ -101,9 +101,19 @@ class PosOrderLine(models.Model): # Handle lines that are actually allowed to be updated to waiting remaining_lines = self.filtered(lambda l: l.preparation_status not in ['served', 'ready', 'preparing']) if remaining_lines: - return super(PosOrderLine, remaining_lines).write(vals) + res = super(PosOrderLine, remaining_lines).write(vals) + # If quantity changed or status is waiting, notify KDS to refresh + remaining_lines._notify_kds() + return res return True - return super(PosOrderLine, self).write(vals) + + res = super(PosOrderLine, self).write(vals) + # Notify KDS for quantity changes on active items + if 'qty' in vals: + active_lines = self.filtered(lambda l: l.preparation_status in ['waiting', 'preparing']) + if active_lines: + active_lines._notify_kds() + return res def action_start_preparing(self): self.write({ diff --git a/addons/dine360_kds/static/src/js/kds_backend.js b/addons/dine360_kds/static/src/js/kds_backend.js index 98c2947..987f5e4 100644 --- a/addons/dine360_kds/static/src/js/kds_backend.js +++ b/addons/dine360_kds/static/src/js/kds_backend.js @@ -63,8 +63,21 @@ export class KdsKanbanController extends KanbanController { if (shouldReload) { // Reload the view to show the new order - console.log("[KDS Controller] Reloading view..."); - this.model.load(); + // Adding a small delay to ensure the transaction is fully committed and indexed + console.log("[KDS Controller] New order received. Reloading view in 1.5s..."); + setTimeout(async () => { + try { + await this.model.load(); + console.log("[KDS Controller] View reloaded. Current record count:", this.model.root.count); + + // Force a re-render if the view still thinks it's empty + if (this.model.root.count > 0) { + this.render(); + } + } catch (error) { + console.error("[KDS Controller] Error during reload:", error); + } + }, 1500); } } } diff --git a/addons/dine360_kds/static/src/js/pos_kds.js b/addons/dine360_kds/static/src/js/pos_kds.js index cb103ca..02f2c5e 100644 --- a/addons/dine360_kds/static/src/js/pos_kds.js +++ b/addons/dine360_kds/static/src/js/pos_kds.js @@ -52,6 +52,14 @@ patch(Orderline.prototype, { 'cancelled': 'Cancelled' }; return labels[this.preparation_status] || this.preparation_status; + }, + + can_be_merged_with(line) { + // Prevent merging if the existing line is already being prepared or served + if (this.preparation_status && this.preparation_status !== 'waiting') { + return false; + } + return super.can_be_merged_with(...arguments); } }); diff --git a/addons/dine360_kds/views/pos_order_line_views.xml b/addons/dine360_kds/views/pos_order_line_views.xml index 6072efc..4107624 100644 --- a/addons/dine360_kds/views/pos_order_line_views.xml +++ b/addons/dine360_kds/views/pos_order_line_views.xml @@ -4,7 +4,7 @@ pos.order.line.kds.kanban pos.order.line - +