From ebc118ee195abfcb5c5cc2c36b08e50681f3e037 Mon Sep 17 00:00:00 2001 From: Florent de Labarre Date: Tue, 22 Nov 2022 23:30:56 +0000 Subject: [PATCH] [FIX] loyalty : don't raise if user have not access to all reward Before this commit it is possible to archive a product if the current user have no access to all reward (multi company rules). closes odoo/odoo#106574 X-original-commit: 5bafee8d0479367fd25b2fa2daefd4374ab38211 Signed-off-by: William Braeckman (wbr) --- addons/loyalty/models/product_product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/loyalty/models/product_product.py b/addons/loyalty/models/product_product.py index 772291d1029..9193f258283 100644 --- a/addons/loyalty/models/product_product.py +++ b/addons/loyalty/models/product_product.py @@ -10,7 +10,7 @@ class ProductProduct(models.Model): def write(self, vals): if not vals.get('active', True) and any(product.active for product in self): # Prevent archiving products used for giving rewards - rewards = self.env['loyalty.reward'].search([('discount_line_product_id', 'in', self.ids)]) + rewards = self.env['loyalty.reward'].sudo().search([('discount_line_product_id', 'in', self.ids)], limit=1) if rewards: raise ValidationError(_("This product may not be archived. It is being used for an active promotion program.")) return super().write(vals)