From 0aacb7ce1792c72c457d80de2ba93e1a1f06cf04 Mon Sep 17 00:00:00 2001
From: fappels <francis.appels@yahoo.com>
Date: Mon, 5 Dec 2016 18:14:03 +0100
Subject: [PATCH] Filter stock on warehouse status for shipping

Do not show stock of closed and internal warehouse.
---
 htdocs/expedition/card.php                   | 2 +-
 htdocs/expedition/class/expedition.class.php | 2 +-
 htdocs/expedition/shipment.php               | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index 5187d2e979a..edb0d42321c 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -862,7 +862,7 @@ if ($action == 'create')
                 if ($line->fk_product > 0)  // If predefined product
                 {
                     $product->fetch($line->fk_product);
-                    $product->load_stock();
+                    $product->load_stock('warehouseopen');
 
                     print '<td>';
                     print '<a name="'.$line->rowid.'"></a>'; // ancre pour retourner sur la ligne
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 1ae5556a898..971a2189854 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -892,7 +892,7 @@ class Expedition extends CommonObject
 				$result=$product->fetch($fk_product);
 
 				if ($entrepot_id > 0) {
-					$product->load_stock();
+					$product->load_stock('warehouseopen');
 					$product_stock = $product->stock_warehouse[$entrepot_id]->real;
 				}
 				else
diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php
index 887b5805533..3044a1beb10 100644
--- a/htdocs/expedition/shipment.php
+++ b/htdocs/expedition/shipment.php
@@ -766,7 +766,7 @@ if ($id > 0 || ! empty($ref))
 				{
 					$product = new Product($db);
 					$product->fetch($objp->fk_product);
-					$product->load_stock();
+					$product->load_stock('warehouseopen');
 				}
 
 				if ($objp->fk_product > 0 && $type == 0 && ! empty($conf->stock->enabled))
-- 
GitLab