From cfc7df15a75d5ca99ec2d326f294a4e13e7299c5 Mon Sep 17 00:00:00 2001 From: Mahamadasif Ansari Date: Wed, 7 Jun 2023 06:34:32 +0000 Subject: [PATCH] [FIX] point_of_sale: prevent ValueError when tip product is deleted "ValueError: No record found for unique ID point_of_sale.product_product_tip. It may have been deleted." is generated when user delete 'Tips' from the product and try to enable tip payment from the POS setting. Step to produce: 1. Install point_of_sale 2. Open product and delete 'Tips' product 3. Open POS > Configure > Setting 4. Enable Tips in payment > select any product in tip product 5. click save >>> Traceback generated This commit solves the above issue by passing 'raise_if_not_found=False' to ensure it does not throw an error when the tip product is not found. sentry-4232555961 closes odoo/odoo#124435 X-original-commit: b3675accd7d4ddfe97712060cda1259cf0b131f6 Signed-off-by: Joseph Caburnay (jcb) Signed-off-by: ANSARI MAHAMADASIF (maan) --- addons/point_of_sale/models/pos_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index d7061d5e29c..958d2bdbc82 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -246,7 +246,7 @@ class PosConfig(models.Model): @api.depends('iface_tipproduct') def _compute_tip_product_id(self): for pos_config in self: - pos_config.tip_product_id = self.env.ref("point_of_sale.product_product_tip") + pos_config.tip_product_id = self.env.ref("point_of_sale.product_product_tip", raise_if_not_found=False) if not pos_config.tip_product_id: pos_config.tip_product_id = self.env['product.product'].search([('default_code', '=', 'TIPS')], limit=1)