From 4815198416fb9d9e5f313a688e4c9a785f309dbe Mon Sep 17 00:00:00 2001
From: "Pedram (PEBR)" <pebr@odoo.com>
Date: Wed, 20 Sep 2023 09:14:54 +0200
Subject: [PATCH] [FIX] pos_restaurant: Avoid error when order table is deleted

When an order's associated table is deleted, the POS tries to load the
table name to display in the order list. This results in an error if
the table no longer exists.

To prevent this, only display the table name if the table still exists
for the order. This avoids the error when trying to load a deleted
table.

opw-3509678

closes odoo/odoo#135970

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
---
 addons/pos_restaurant/static/src/js/Screens/TicketScreen.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js b/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js
index 6a4c1f3bc991..6befe5924227 100644
--- a/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js
+++ b/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js
@@ -31,7 +31,8 @@ odoo.define('pos_restaurant.TicketScreen', function (require) {
                 });
             }
             getTable(order) {
-                return `${order.getTable().floor.name} (${order.getTable().name})`;
+                const table = order.getTable();
+                return table ? `${table.floor.name} (${table.name})` : '';
             }
             //@override
             _getSearchFields() {
-- 
GitLab