[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
This commit is contained in:
committed by
Goffin Simon
parent
b9edb91418
commit
bc3d5ca775
@@ -15,6 +15,22 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user