pos_kds_report/models/pos_prep_display.py

33 lines
1.5 KiB
Python

from odoo import models
class PosPrepDisplay(models.Model):
_inherit = 'pos.prep.display'
def _notify(self, *notifications, private=True) -> None:
new_notifications = []
if isinstance(notifications[0], str):
if len(notifications) == 2:
name, message = notifications
if name == 'CHANGE_STATE_STAGE' and isinstance(message, dict):
stages = message.get('pdis_state_stages', [])
for stage_data in stages:
state = self.env['pos.prep.state'].browse(stage_data['id'])
if state.exists():
stage_data['kds_accumulated_time'] = state.kds_accumulated_time
new_notifications = notifications
else:
for item in notifications:
if isinstance(item, tuple) and len(item) == 2:
name, message = item
if name == 'CHANGE_STATE_STAGE' and isinstance(message, dict):
stages = message.get('pdis_state_stages', [])
for stage_data in stages:
state = self.env['pos.prep.state'].browse(stage_data['id'])
if state.exists():
stage_data['kds_accumulated_time'] = state.kds_accumulated_time
new_notifications.append((name, message))
else:
new_notifications.append(item)
super()._notify(*new_notifications, private=private)