Skip to content

Commit

Permalink
[FIX] stock: UserError message improvement
Browse files Browse the repository at this point in the history
To know the product still having some active reordering rules.
Closes odoo#22615
opw:813476
  • Loading branch information
fmdl authored and simongoffin committed Feb 15, 2018
1 parent c1276c1 commit 9a67c8b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions addons/stock/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,14 @@ def action_view_routes(self):
@api.multi
def write(self, values):
res = super(Product, self).write(values)
if 'active' in values and not values['active'] and self.mapped('orderpoint_ids').filtered(lambda r: r.active):
raise UserError(_('You still have some active reordering rules on this product. Please archive or delete them first.'))
if 'active' in values and not values['active']:
products = self.mapped('orderpoint_ids').filtered(lambda r: r.active).mapped('product_id')
if products:
msg = _('You still have some active reordering rules on this product. Please archive or delete them first.')
msg += '\n\n'
for product in products:
msg += '- %s \n' % product.display_name
raise UserError(msg)
return res

class ProductTemplate(models.Model):
Expand Down

0 comments on commit 9a67c8b

Please sign in to comment.