Skip to content
Snippets Groups Projects
Commit 06a80459 authored by Hetashree Chauhan's avatar Hetashree Chauhan Committed by Pierre Masereel
Browse files

[REF] stock,uom: error message more clear

Change to more understable error messages

TASK-1841502
parent 9f847076
No related branches found
No related tags found
No related merge requests found
...@@ -509,7 +509,7 @@ class ProductTemplate(models.Model): ...@@ -509,7 +509,7 @@ class ProductTemplate(models.Model):
updated = self.filtered(lambda template: template.uom_id != new_uom) updated = self.filtered(lambda template: template.uom_id != new_uom)
done_moves = self.env['stock.move'].search([('product_id', 'in', updated.with_context(active_test=False).mapped('product_variant_ids').ids)], limit=1) done_moves = self.env['stock.move'].search([('product_id', 'in', updated.with_context(active_test=False).mapped('product_variant_ids').ids)], limit=1)
if done_moves: if done_moves:
raise UserError(_("You can not change the unit of measure of a product that has already been used in a done stock move. If you need to change the unit of measure, you may deactivate this product.")) raise UserError(_("You cannot change the unit of measure as there are already stock moves for this product. If you want to change the unit of measure, you should rather archive this product and create a new one."))
if 'type' in vals and vals['type'] != 'product' and sum(self.mapped('nbr_reordering_rules')) != 0: if 'type' in vals and vals['type'] != 'product' and sum(self.mapped('nbr_reordering_rules')) != 0:
raise UserError(_('You still have some active reordering rules on this product. Please archive or delete them first.')) raise UserError(_('You still have some active reordering rules on this product. Please archive or delete them first.'))
if any('type' in vals and vals['type'] != prod_tmpl.type for prod_tmpl in self): if any('type' in vals and vals['type'] != prod_tmpl.type for prod_tmpl in self):
......
...@@ -135,7 +135,7 @@ class UoM(models.Model): ...@@ -135,7 +135,7 @@ class UoM(models.Model):
self.ensure_one() self.ensure_one()
if self.category_id.id != to_unit.category_id.id: if self.category_id.id != to_unit.category_id.id:
if raise_if_failure: if raise_if_failure:
raise UserError(_('Conversion from Product UoM %s to Default UoM %s is not possible as they both belong to different Category!.') % (self.name, to_unit.name)) raise UserError(_('The unit of measure %s defined on the order line doesn\'t belong to the same category than the unit of measure %s defined on the product. Please correct the unit of measure defined on the order line or on the product, they should belong to the same category.') % (self.name, to_unit.name))
else: else:
return qty return qty
amount = qty / self.factor amount = qty / self.factor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment