diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 2bd20c551944025db518ed5bb28922b56059d5e7..8f618e2fbf031a696247fa691fd8228661e0731e 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -3947,7 +3947,7 @@ abstract class CommonObject
 
 					// Now we add first model found in directories scanned
 	                $listofdir=explode(',',$dirtoscan);
-	                foreach($listofdir as $key=>$tmpdir)
+	                foreach($listofdir as $key => $tmpdir)
 	                {
 	                    $tmpdir=trim($tmpdir);
 	                    $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index 98bd412abc23cca278c1ad7906bd3864a75619a1..a3f8676fb651e6106cae068fd1dd1a961dd338aa 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -1447,55 +1447,55 @@ class DolibarrModules           // Can not be abstract, because we need to insta
      *
      * @return int  Error count (0 if ok)
      */
-    function insert_tabs()
-    {
-        global $conf;
-
-        $err=0;
-
-        if (! empty($this->tabs))
-        {
-            $i=0;
-            foreach ($this->tabs as $key => $value)
-            {
-            	if (is_array($value) && count($value) == 0) continue;	// Discard empty arrays
-
-            	$entity=$conf->entity;
-            	$newvalue = $value;
-
-            	if (is_array($value))
-            	{
-            		$newvalue = $value['data'];
-            		if (isset($value['entity'])) $entity = $value['entity'];
-            	}
-
-                if ($newvalue)
-                {
-                    $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";
-                    $sql.= "name";
-                    $sql.= ", type";
-                    $sql.= ", value";
-                    $sql.= ", note";
-                    $sql.= ", visible";
-                    $sql.= ", entity";
-                    $sql.= ")";
-                    $sql.= " VALUES (";
-                    $sql.= $this->db->encrypt($this->const_name."_TABS_".$i,1);
-                    $sql.= ", 'chaine'";
-                    $sql.= ", ".$this->db->encrypt($value,1);
-                    $sql.= ", null";
-                    $sql.= ", '0'";
-                    $sql.= ", ".$conf->entity;
-                    $sql.= ")";
-
-                    dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG);
-                    $this->db->query($sql);
-                }
-                $i++;
-            }
-        }
-        return $err;
-    }
+	function insert_tabs()
+	{
+		global $conf;
+
+		$err=0;
+
+		if (! empty($this->tabs))
+		{
+			$i=0;
+			foreach ($this->tabs as $key => $value)
+			{
+				if (is_array($value) && count($value) == 0) continue;	// Discard empty arrays
+
+				$entity=$conf->entity;
+				$newvalue = $value;
+
+				if (is_array($value))
+				{
+					$newvalue = $value['data'];
+					if (isset($value['entity'])) $entity = $value['entity'];
+				}
+
+				if ($newvalue)
+				{
+					$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";
+					$sql.= "name";
+					$sql.= ", type";
+					$sql.= ", value";
+					$sql.= ", note";
+					$sql.= ", visible";
+					$sql.= ", entity";
+					$sql.= ")";
+					$sql.= " VALUES (";
+					$sql.= $this->db->encrypt($this->const_name."_TABS_".$i,1);
+					$sql.= ", 'chaine'";
+					$sql.= ", ".$this->db->encrypt($newvalue,1);
+					$sql.= ", null";
+					$sql.= ", '0'";
+					$sql.= ", ".$entity;
+					$sql.= ")";
+
+					dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG);
+					$this->db->query($sql);
+				}
+				$i++;
+			}
+		}
+		return $err;
+	}
 
     /**
      * Adds constants
diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
index 03ff8c76d935f68cb5a75443ff4715b4b2a6ad23..48a6b191ebf47cd3ccdd7902ea16fff647b53fbf 100644
--- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
+++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
@@ -611,3 +611,7 @@ INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (14
 -- VMYSQL4.1 ALTER TABLE llx_c_type_resource CHANGE COLUMN rowid rowid integer NOT NULL AUTO_INCREMENT;
 
 ALTER TABLE llx_import_model MODIFY COLUMN type varchar(50);
+
+-- Negative buying prices
+
+UPDATE llx_facturedet SET buy_price_ht = ABS(buy_price_ht)
diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang
index 460665255b1a20bf8862d59e003372c2ab4eab8a..11c013cb76867510f87a83adc6d9495ada097ef2 100644
--- a/htdocs/langs/en_US/stocks.lang
+++ b/htdocs/langs/en_US/stocks.lang
@@ -69,6 +69,7 @@ NoPredefinedProductToDispatch=No predefined products for this object. So no disp
 DispatchVerb=Dispatch
 StockLimitShort=Limit for alert
 StockLimit=Stock limit for alert
+StockLimitDesc="" (empty) default value means no alert. <br>"0" can be used with 'Stock can be negative' configuration.
 PhysicalStock=Physical stock
 RealStock=Real Stock
 RealStockDesc=Physical or real stock is the stock you currently have into your internal warehouses/emplacements. 
@@ -192,4 +193,4 @@ InventoryFlushed=Inventory flushed
 ExitEditMode=Exit edition
 inventoryDeleteLine=Delete line
 RegulateStock=Regulate Stock
-ListInventory=List
+ListInventory=List
\ No newline at end of file