From 9a7c187147e6277373579d720b2b3cc67063b40b Mon Sep 17 00:00:00 2001 From: vlst Date: Mon, 28 Aug 2023 16:12:27 +0200 Subject: [PATCH] [IMP] point_of_sale: enable combo products Products can be created directly from the `pos.combo` view. Before this PR, such products would not be automatically available in the POS app. This PR makes it so products linked to combos are available in POS by default. We also introduce an additional check that makes it so products associated to combos cannot be disabled in the pos. In this commit we also make it so the `Office Combo` product from the pos demo data is in the `Desks` `pos_category`. closes odoo/odoo#133359 Task: 3481899 Signed-off-by: Joseph Caburnay (jcb) --- addons/point_of_sale/data/point_of_sale_demo.xml | 1 + addons/point_of_sale/models/product.py | 7 +++++++ addons/point_of_sale/views/pos_combo_view.xml | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/data/point_of_sale_demo.xml b/addons/point_of_sale/data/point_of_sale_demo.xml index 2a13b95a59e..342de906143 100644 --- a/addons/point_of_sale/data/point_of_sale_demo.xml +++ b/addons/point_of_sale/data/point_of_sale_demo.xml @@ -464,6 +464,7 @@ Office combo combo + diff --git a/addons/point_of_sale/models/product.py b/addons/point_of_sale/models/product.py index 7046e87d78e..b223e5e5abd 100644 --- a/addons/point_of_sale/models/product.py +++ b/addons/point_of_sale/models/product.py @@ -35,6 +35,13 @@ class ProductTemplate(models.Model): if not self.sale_ok: self.available_in_pos = False + @api.constrains('available_in_pos') + def _check_combo_inclusions(self): + for product in self: + if not product.available_in_pos: + combo_name = self.env['pos.combo.line'].search([('product_id', 'in', product.product_variant_ids.ids)], limit=1).combo_id.name + if combo_name: + raise UserError(_('You must first remove this product from the %s combo') % combo_name) class ProductProduct(models.Model): _inherit = 'product.product' diff --git a/addons/point_of_sale/views/pos_combo_view.xml b/addons/point_of_sale/views/pos_combo_view.xml index 22c4f1e8ce5..efe96fa3f1e 100644 --- a/addons/point_of_sale/views/pos_combo_view.xml +++ b/addons/point_of_sale/views/pos_combo_view.xml @@ -13,7 +13,7 @@ - +