Add Kitchen Display System (KDS) with real-time order status management and a dedicated Kanban view for order lines.

This commit is contained in:
Alaguraj0361 2026-02-16 16:17:11 +05:30
parent 7956d96bcc
commit 3983b6a66d
4 changed files with 36 additions and 5 deletions

View File

@ -101,9 +101,19 @@ class PosOrderLine(models.Model):
# Handle lines that are actually allowed to be updated to waiting # 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']) remaining_lines = self.filtered(lambda l: l.preparation_status not in ['served', 'ready', 'preparing'])
if remaining_lines: 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 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): def action_start_preparing(self):
self.write({ self.write({

View File

@ -63,8 +63,21 @@ export class KdsKanbanController extends KanbanController {
if (shouldReload) { if (shouldReload) {
// Reload the view to show the new order // Reload the view to show the new order
console.log("[KDS Controller] Reloading view..."); // Adding a small delay to ensure the transaction is fully committed and indexed
this.model.load(); 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);
} }
} }
} }

View File

@ -52,6 +52,14 @@ patch(Orderline.prototype, {
'cancelled': 'Cancelled' 'cancelled': 'Cancelled'
}; };
return labels[this.preparation_status] || this.preparation_status; 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);
} }
}); });

View File

@ -4,7 +4,7 @@
<field name="name">pos.order.line.kds.kanban</field> <field name="name">pos.order.line.kds.kanban</field>
<field name="model">pos.order.line</field> <field name="model">pos.order.line</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<kanban js_class="kds_kanban" default_group_by="preparation_status" create="false" class="o_kanban_small_column o_kanban_project_tasks" sample="1"> <kanban js_class="kds_kanban" default_group_by="preparation_status" create="false" class="o_kanban_small_column o_kanban_project_tasks">
<field name="preparation_status"/> <field name="preparation_status"/>
<field name="color"/> <field name="color"/>
<field name="product_id"/> <field name="product_id"/>