Skip to content
Snippets Groups Projects
Commit 9481e58f authored by Florent de Labarre's avatar Florent de Labarre
Browse files

[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#106559

X-original-commit: 5bafee8d0479367fd25b2fa2daefd4374ab38211
Signed-off-by: default avatarWilliam Braeckman (wbr) <wbr@odoo.com>
parent 48b6be9d
Branches
Tags
No related merge requests found
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment