I am working on an Odoo 18 POS system and I need to implement a feature where a POS order is cancelled from the backend (via Python), and once cancelled, the frontend should be notified in real-time to update the order status without requiring a manual refresh.
Here is the backend code where the order is being cancelled
class PosOrderCancelWizard(models.TransientModel):
_name = 'pos.order.cancel.wizard'
_description = 'POS Order Cancel Wizard'
reason = fields.Text(string="Reason", required=True)
order_id = fields.Many2one('pos.order', string="POS Order", required=True, default=lambda self: self.env.context.get('default_order_id'))
def action_confirm(self):
self.ensure_one()
if self.order_id:
self.order_id.reason = self.reason
self.order_id.action_pos_order_cancel()