From 19df0d9ba00263b66cbe70ee635b4e0a6751ef50 Mon Sep 17 00:00:00 2001 From: "Pedram (PEBR)" Date: Fri, 1 Dec 2023 13:06:22 +0000 Subject: [PATCH] [FIX] pos_restaurant: exclude archived floors in get_tables_order_count Before this commit, archiving a restaurant floor caused an error when opening a PoS restaurant session. This issue originated from the `get_tables_order_count` function, which executed a search based on `restaurant.table`. Since archiving a floor does not automatically archive its tables, the function returned information for archived floors, leading to errors. With this commit, we introduce an additional search to first identify active floors in a PoS config. This refined search is then used to filter tables, ensuring that only tables from active floors are considered. opw-3619830 closes odoo/odoo#145052 X-original-commit: b3ec68c4091276566db32f13346d4440128e42a9 Signed-off-by: Joseph Caburnay (jcb) Signed-off-by: Pedram Bi Ria (pebr) --- addons/pos_restaurant/models/pos_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/pos_restaurant/models/pos_config.py b/addons/pos_restaurant/models/pos_config.py index 5ccc79495e0..e00101fdefb 100644 --- a/addons/pos_restaurant/models/pos_config.py +++ b/addons/pos_restaurant/models/pos_config.py @@ -19,7 +19,8 @@ class PosConfig(models.Model): def get_tables_order_count_and_printing_changes(self): self.ensure_one() - tables = self.env['restaurant.table'].search([('floor_id.pos_config_ids', '=', self.id)]) + floors = self.env['restaurant.floor'].search([('pos_config_ids', '=', self.id)]) + tables = self.env['restaurant.table'].search([('floor_id', 'in', floors.ids)]) domain = [('state', '=', 'draft'), ('table_id', 'in', tables.ids)] order_stats = self.env['pos.order']._read_group(domain, ['table_id'], ['__count'])