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
-
+