From 06a804596ebc0e9407003fafd705706c3af07dfe Mon Sep 17 00:00:00 2001
From: Hetashree Chauhan <hch@odoo.com>
Date: Wed, 16 May 2018 16:04:21 +0530
Subject: [PATCH] [REF] stock,uom: error message more clear

Change to more understable error messages

TASK-1841502
---
 addons/stock/models/product.py | 2 +-
 addons/uom/models/uom_uom.py   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py
index ae8cc4d98fd0..c257b07f6aab 100644
--- a/addons/stock/models/product.py
+++ b/addons/stock/models/product.py
@@ -509,7 +509,7 @@ class ProductTemplate(models.Model):
             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)
             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:
             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):
diff --git a/addons/uom/models/uom_uom.py b/addons/uom/models/uom_uom.py
index 6573c7541fbf..5782c7f4dacc 100644
--- a/addons/uom/models/uom_uom.py
+++ b/addons/uom/models/uom_uom.py
@@ -135,7 +135,7 @@ class UoM(models.Model):
         self.ensure_one()
         if self.category_id.id != to_unit.category_id.id:
             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:
                 return qty
         amount = qty / self.factor
-- 
GitLab