[FIX] stock: UserError message improvement
To know the product still having some active reordering rules. Closes #22615 opw:813476
This commit is contained in:
committed by
Goffin Simon
parent
c1276c154e
commit
9a67c8b946
@@ -371,8 +371,14 @@ class Product(models.Model):
|
||||
@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):
|
||||
|
||||
Reference in New Issue
Block a user