From 0a8c5c12e522fe69d3784281fb6f0af1f77b87d0 Mon Sep 17 00:00:00 2001 From: Dhaval Panchal Date: Thu, 3 Aug 2017 18:34:34 +0530 Subject: [PATCH] [IMP] sale_stock: display quantity available in other warehouses When we are creating a sale order line of a product that doesn't have sufficient quantity in stock, we get a warning saying that you don't have the quantity entered in stock. We improved this warnig by showing the remaining quantities in the other warehouses of the company. --- addons/sale_stock/models/sale_order.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index e61adb554b1..b7d06ae056a 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -176,9 +176,12 @@ class SaleOrderLine(models.Model): (self.product_uom_qty, self.product_uom.name, product.virtual_available, product.uom_id.name, self.order_id.warehouse_id.name) # We check if some products are available in other warehouses. if float_compare(product.virtual_available, self.product_id.virtual_available, precision_digits=precision) == -1: - message += _('\nThere are %s %s available accross all warehouses.') % \ + message += _('\nThere are %s %s available across all warehouses.\n\n') % \ (self.product_id.virtual_available, product.uom_id.name) - + for warehouse in self.env['stock.warehouse'].search([]): + quantity = self.product_id.with_context(warehouse=warehouse.id).virtual_available + if quantity > 0: + message += "%s: %s %s\n" % (warehouse.name, quantity, self.product_id.uom_id.name) warning_mess = { 'title': _('Not enough inventory!'), 'message' : message