[FIX] stock: Error message don't contain the name of product

The message don't show the name of product.

Before the fix:

The message was: "It is not possible to reserve more products of than you have in stock."

After the fix:

The message is: "It is not possible to reserve more products of [0221] Product A than you have in stock."

opw:1868449
This commit is contained in:
Florent de Labarre
2018-07-23 12:09:12 +02:00
committed by Goffin Simon
parent e91f10f14d
commit 3528e804de
+2 -2
View File
@@ -262,12 +262,12 @@ class StockQuant(models.Model):
# if we want to reserve
available_quantity = self._get_available_quantity(product_id, location_id, lot_id=lot_id, package_id=package_id, owner_id=owner_id, strict=strict)
if float_compare(quantity, available_quantity, precision_rounding=rounding) > 0:
raise UserError(_('It is not possible to reserve more products of %s than you have in stock.') % (', '.join(quants.mapped('product_id').mapped('display_name'))))
raise UserError(_('It is not possible to reserve more products of %s than you have in stock.') % product_id.display_name)
elif float_compare(quantity, 0, precision_rounding=rounding) < 0:
# if we want to unreserve
available_quantity = sum(quants.mapped('reserved_quantity'))
if float_compare(abs(quantity), available_quantity, precision_rounding=rounding) > 0:
raise UserError(_('It is not possible to unreserve more products of %s than you have in stock.') % (', '.join(quants.mapped('product_id').mapped('display_name'))))
raise UserError(_('It is not possible to unreserve more products of %s than you have in stock.') % product_id.display_name)
else:
return reserved_quants