summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorFlorent de Labarre <florent.mirieu@gmail.com>2017-10-18 03:56:42 -0800
committerGoffin Simon <sig@odoo.com>2018-01-08 10:10:33 +0100
commitbc3d5ca7755d8a0d9a3e4c185b26e201ed8fefc3 (patch)
treef8a7b5ed864c1b2f968e902077847a02ee69de20 /addons
parentb9edb91418de5a9d5855eea166d0149ec0d730bb (diff)
[FIX] stock.move : add more information in UserError of product_uom Constrains
Steps to reproduce the bug: - Create a bom with lines - Change on one product in product view form the uom with diffrent category (exemple : unit -> meter) - Create un manufactoring order : you have an error You try to move a product using a UoM that is not compatible with the UoM of the product moved. Please use an UoM in the same UoM category., the error message doesn't give with product there are an issue. ( if you have hundred of line in your Bom, it is very difficult). This fix improves the error message. opw:800328
Diffstat (limited to 'addons')
-rw-r--r--addons/stock/i18n/stock.pot16
-rw-r--r--addons/stock/models/stock_move.py6
2 files changed, 20 insertions, 2 deletions
diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot
index d3a06ce060f..559aa1d3b85 100644
--- a/addons/stock/i18n/stock.pot
+++ b/addons/stock/i18n/stock.pot
@@ -16,6 +16,22 @@ msgstr ""
"Plural-Forms: \n"
#. module: stock
+#: code:addons/stock/models/stock_move.py:230
+#, python-format
+msgid "\n"
+"\n"
+"%s --> Product UoM is %s (%s) - Move UoM is %s (%s)"
+msgstr ""
+
+#. module: stock
+#: code:addons/stock/models/stock_move.py:231
+#, python-format
+msgid "\n"
+"\n"
+"Blocking: %s"
+msgstr ""
+
+#. module: stock
#: model:ir.model.fields,help:stock.field_stock_config_settings_module_stock_dropshipping
msgid "\n"
"Creates the dropship route and add more complex tests\n"
diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py
index 719bf08ea1a..2cd17da87ed 100644
--- a/addons/stock/models/stock_move.py
+++ b/addons/stock/models/stock_move.py
@@ -223,10 +223,12 @@ class StockMove(models.Model):
@api.constrains('product_uom')
def _check_uom(self):
- moves_error = self.filtered(lambda move: move.product_id.uom_id.category_id.id != move.product_uom.category_id.id)
+ moves_error = self.filtered(lambda move: move.product_id.uom_id.category_id != move.product_uom.category_id)
if moves_error:
user_warning = _('You try to move a product using a UoM that is not compatible with the UoM of the product moved. Please use an UoM in the same UoM category.')
- user_warning += '\n\nBlocking: %s' % ' ,'.join(moves_error.mapped('name'))
+ for move in moves_error:
+ user_warning += _('\n\n%s --> Product UoM is %s (%s) - Move UoM is %s (%s)') % (move.product_id.display_name, move.product_id.uom_id.name, move.product_id.uom_id.category_id.name, move.product_uom.name, move.product_uom.category_id.name)
+ user_warning += _('\n\nBlocking: %s') % ' ,'.join(moves_error.mapped('name'))
raise UserError(user_warning)
@api.model_cr