From 4cf6e2992ff519c41dff845714e42d7c6161b4ce Mon Sep 17 00:00:00 2001 From: payen000 Date: Wed, 11 Jan 2023 15:36:22 +0000 Subject: [PATCH] [REF] pos_restaurant: making pos.order's 'get_table_draft_orders' inheritance friendly By making the search_read inside 'get_table_draft_orders' non-hardcoded, its domain can now be modified by inheriting _get_domain_from_draft_orders from other modules. closes odoo/odoo#111609 X-original-commit: 64156e5ed6a9825bdbe2277783f250b471636004 Signed-off-by: Trinh Jacky (trj) --- addons/pos_restaurant/models/pos_order.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/pos_restaurant/models/pos_order.py b/addons/pos_restaurant/models/pos_order.py index 9f98e7da6b6..89145bcc002 100644 --- a/addons/pos_restaurant/models/pos_order.py +++ b/addons/pos_restaurant/models/pos_order.py @@ -162,6 +162,14 @@ class PosOrder(models.Model): 'access_token', ] + def _get_domain_for_draft_orders(self, table_ids): + """ Get the domain to search for draft orders on a table. + :param table_ids: Ids of the selected tables. + :type table_ids: list of int. + "returns: list -- list of tuples that represents a domain. + """ + return [('state', '=', 'draft'), ('table_id', 'in', table_ids)] + @api.model def get_table_draft_orders(self, table_ids): """Generate an object of all draft orders for the given table. @@ -169,12 +177,12 @@ class PosOrder(models.Model): Generate and return an JSON object with all draft orders for the given table, to send to the front end application. - :param table_id: Id of the selected table. - :type table_id: int. + :param table_ids: Ids of the selected tables. + :type table_ids: list of int. :returns: list -- list of dict representing the table orders """ table_orders = self.search_read( - domain=[('state', '=', 'draft'), ('table_id', 'in', table_ids)], + domain=self._get_domain_for_draft_orders(table_ids), fields=self._get_fields_for_draft_order()) self._get_order_lines(table_orders)