Add Kitchen Display System (KDS) with real-time order status management and a dedicated Kanban view for order lines.
This commit is contained in:
parent
7956d96bcc
commit
3983b6a66d
@ -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({
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<field name="name">pos.order.line.kds.kanban</field>
|
||||
<field name="model">pos.order.line</field>
|
||||
<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="color"/>
|
||||
<field name="product_id"/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user