From ee29c6570894fedfd7cf1ba2a5f5435f72819ca0 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sat, 27 Oct 2012 20:27:07 +0200
Subject: [PATCH] Move stock import into stock module (stock module is at a low
 level than product)

---
 htdocs/core/modules/modProduct.class.php | 23 +----------------------
 htdocs/core/modules/modStock.class.php   | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php
index 87114427243..3c2a7c7b582 100644
--- a/htdocs/core/modules/modProduct.class.php
+++ b/htdocs/core/modules/modProduct.class.php
@@ -223,28 +223,7 @@ class modProduct extends DolibarrModules
 					'sp.remise_percent'=>'0'
 			);
 		}
-		
-		if (! empty($conf->stock->enabled))
-		{
-			// Import stocks
-			$r++;
-			$this->import_code[$r]=$this->rights_class.'_'.$r;
-			$this->import_label[$r]="Stocks";	// Translation key
-			$this->import_icon[$r]='stock';
-			$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
-			$this->import_tables_array[$r]=array('ps'=>MAIN_DB_PREFIX.'product_stock');
-			$this->import_fields_array[$r]=array('ps.fk_product'=>"Product*",'ps.fk_entrepot'=>"Warehouse*",
-					'ps.reel'=>"Stock*",'ps.pmp'=>"PMP"
-			);
-			
-			$this->import_convertvalue_array[$r]=array(
-					'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'),
-					'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'label')
-			);
-			$this->import_examplevalues_array[$r]=array('ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",
-					'ps.reel'=>"10",'ps.pmp'=>"25"
-			);
-		}
+
 	}
 
 
diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php
index f1cbb58f469..41e127b001e 100644
--- a/htdocs/core/modules/modStock.class.php
+++ b/htdocs/core/modules/modStock.class.php
@@ -139,6 +139,7 @@ class modStock extends DolibarrModules
 
 		$r=0;
 
+		// Import warehouses
 		$r++;
 		$this->import_code[$r]=$this->rights_class.'_'.$r;
 		$this->import_label[$r]="Warehouses";	// Translation key
@@ -160,6 +161,23 @@ class modStock extends DolibarrModules
 				'e.description'=>"Central Warehouse",'e.lieu'=>"Central",
 				'e.address'=>"Route 66",'e.cp'=>'28080','e.fk_pays'=>'US',
 				'e.statut'=>'1');
+
+		// Import stocks
+		$r++;
+		$this->import_code[$r]=$this->rights_class.'_'.$r;
+		$this->import_label[$r]="Stocks";	// Translation key
+		$this->import_icon[$r]=$this->picto;
+		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
+		$this->import_tables_array[$r]=array('ps'=>MAIN_DB_PREFIX.'product_stock');
+		$this->import_fields_array[$r]=array('ps.fk_product'=>"Product*",'ps.fk_entrepot'=>"Warehouse*",'ps.reel'=>"Stock*",'ps.pmp'=>"PMP"	);
+
+		$this->import_convertvalue_array[$r]=array(
+			'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'),
+			'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'label')
+		);
+		$this->import_examplevalues_array[$r]=array('ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10",'ps.pmp'=>"25"
+		);
+
 	}
 
 	/**
-- 
GitLab