forked from alaguraj/odoo-testing-addons
add Kitchen Display System (KDS) functionality with order line preparation status, time tracking, and real-time POS integration.
This commit is contained in:
parent
c2d89273e2
commit
7956d96bcc
@ -2,7 +2,7 @@
|
|||||||
body.o_home_dashboard,
|
body.o_home_dashboard,
|
||||||
#wrapwrap.o_home_dashboard,
|
#wrapwrap.o_home_dashboard,
|
||||||
.o_home_menu_background {
|
.o_home_menu_background {
|
||||||
background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
|
background: linear-gradient(rgb(0 0 0 / 83%), rgb(0 0 0 / 83%)),
|
||||||
url('/dine360_dashboard/static/src/img/dashboard_bg.png') no-repeat center center !important;
|
url('/dine360_dashboard/static/src/img/dashboard_bg.png') no-repeat center center !important;
|
||||||
background-size: cover !important;
|
background-size: cover !important;
|
||||||
background-attachment: fixed !important;
|
background-attachment: fixed !important;
|
||||||
|
|||||||
@ -82,10 +82,29 @@ class PosOrderLine(models.Model):
|
|||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
"""Override create to send notifications to KDS when new orders are added"""
|
"""Override create to send notifications to KDS when new orders are added"""
|
||||||
lines = super(PosOrderLine, self).create(vals_list)
|
lines = super(PosOrderLine, self).create(vals_list)
|
||||||
# Send notification to KDS backend for real-time updates
|
# Send notification to KDS backend only for new items (waiting status)
|
||||||
lines._notify_kds()
|
waiting_lines = lines.filtered(lambda l: l.preparation_status == 'waiting')
|
||||||
|
if waiting_lines:
|
||||||
|
waiting_lines._notify_kds()
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
def write(self, vals):
|
||||||
|
"""Prevent resetting 'served' or 'ready' status back to 'waiting' during POS sync"""
|
||||||
|
if 'preparation_status' in vals and vals['preparation_status'] == 'waiting':
|
||||||
|
for line in self:
|
||||||
|
if line.preparation_status in ['served', 'ready', 'preparing']:
|
||||||
|
# Keep the current status if it's already being processed or served
|
||||||
|
actual_vals = vals.copy()
|
||||||
|
actual_vals['preparation_status'] = line.preparation_status
|
||||||
|
super(PosOrderLine, line).write(actual_vals)
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
return True
|
||||||
|
return super(PosOrderLine, self).write(vals)
|
||||||
|
|
||||||
def action_start_preparing(self):
|
def action_start_preparing(self):
|
||||||
self.write({
|
self.write({
|
||||||
'preparation_status': 'preparing',
|
'preparation_status': 'preparing',
|
||||||
@ -105,3 +124,13 @@ class PosOrderLine(models.Model):
|
|||||||
'preparation_status': 'served'
|
'preparation_status': 'served'
|
||||||
})
|
})
|
||||||
self._notify_pos()
|
self._notify_pos()
|
||||||
|
|
||||||
|
class PosOrder(models.Model):
|
||||||
|
_inherit = 'pos.order'
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _prepare_order_line_vals(self, line, session_id=None):
|
||||||
|
res = super()._prepare_order_line_vals(line, session_id)
|
||||||
|
if 'preparation_status' in line:
|
||||||
|
res['preparation_status'] = line['preparation_status']
|
||||||
|
return res
|
||||||
|
|||||||
@ -13,9 +13,13 @@ console.log("[KDS] Imports successful");
|
|||||||
|
|
||||||
// Patch Orderline model
|
// Patch Orderline model
|
||||||
patch(Orderline.prototype, {
|
patch(Orderline.prototype, {
|
||||||
setup() {
|
setup(attr) {
|
||||||
super.setup(...arguments);
|
super.setup(...arguments);
|
||||||
this.preparation_status = this.preparation_status || 'waiting';
|
if (attr && attr.preparation_status) {
|
||||||
|
this.preparation_status = attr.preparation_status;
|
||||||
|
} else if (!this.preparation_status) {
|
||||||
|
this.preparation_status = 'waiting';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
init_from_JSON(json) {
|
init_from_JSON(json) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user