diff --git a/.travis.yml b/.travis.yml
index 647ed3e6ace26092b6efcfe8187ace60aa5fa466..b205baf4b0c099a5298917c98b87a99cd714850e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -172,8 +172,8 @@ before_script:
   echo
 
 - |
-  echo "Setting up Dolibarr"
   export CONF_FILE=htdocs/conf/conf.php
+  echo "Setting up Dolibarr $CONF_FILE"
   echo '<?php ' > $CONF_FILE
   echo '$'dolibarr_main_url_root=\'http://127.0.0.1\'';' >> $CONF_FILE
   echo '$'dolibarr_main_document_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $CONF_FILE
@@ -190,15 +190,9 @@ before_script:
   #fi
   # TODO: SQLite
   echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE
+  cat $CONF_FILE
   echo
 
-- |
-  if [ "$DEBUG" = true ]; then
-    echo "Debugging informations"
-    cat $CONF_FILE
-    echo
-  fi
-
 - |
   echo "Create documents directory and set permissions"
   # and admin/temp subdirectory needed for unit tests
diff --git a/build/debian/changelog b/build/debian/changelog
index 5d34808d3a6bee6c33395cd36683b9626b738819..326405a6d2bf0f8082915be06f06907035e36e22 100644
--- a/build/debian/changelog
+++ b/build/debian/changelog
@@ -1,4 +1,4 @@
-dolibarr (3.6.5-3) UNRELEASED; urgency=low
+dolibarr (__VERSION__) UNRELEASED; urgency=low
 
   [ Laurent Destailleur (eldy) ]
   * New upstream release.
diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl
index 603fd0f2e7aa5d70e21fdb50eeaf4753b0cbd766..fbae52f972682dddd0a0d2e6dd091e49234aa729 100755
--- a/build/makepack-dolibarr.pl
+++ b/build/makepack-dolibarr.pl
@@ -65,6 +65,13 @@ $DIR||='.'; $DIR =~ s/([^\/\\])[\\\/]+$/$1/;
 
 $SOURCE="$DIR/..";
 $DESTI="$SOURCE/build";
+if ($SOURCE !~ /^\//)
+{
+	print "Error: Launch the script $PROG.$Extension with its full path from /.\n";
+	print "$PROG.$Extension aborted.\n";
+	sleep 2;
+	exit 1;
+}
 if (! $ENV{"DESTIBETARC"} || ! $ENV{"DESTISTABLE"})
 {
 	print "Error: Missing environment variables.\n";
@@ -338,8 +345,8 @@ foreach my $target (sort keys %CHOOSEDPUBLISH) {
 
 if ($nboftargetok) {
 
-	# Update CVS if required
-	#-----------------------
+	# Update GIT tag if required
+	#---------------------------
 	if ($nbofpublishneedtag)
 	{
 		print "Go to directory $SOURCE\n";
@@ -353,7 +360,7 @@ if ($nboftargetok) {
 			print "Error: The ChangeLogFile was not updated. Run the following command first:\n";
 			if (! $BUILD)
 			{
-				print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
+				print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
 			}
 			else
 			{
@@ -443,6 +450,7 @@ if ($nboftargetok) {
 
 		$ret=`rm -fr  $BUILDROOT/$PROJECT/htdocs/install/mssql`;
 
+		$ret=`rm -fr $BUILDROOT/$PROJECT/dev/ansible`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/dev/codesniffer`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/dev/codetemplates`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/dev/dbmodel`;
@@ -451,6 +459,7 @@ if ($nboftargetok) {
 		$ret=`rm -fr $BUILDROOT/$PROJECT/dev/ldap`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/dev/licence`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/dev/mail`;
+		$ret=`rm -fr $BUILDROOT/$PROJECT/dev/multitail`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/dev/phpcheckstyle`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/dev/phpunit`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/dev/security`;
@@ -478,23 +487,28 @@ if ($nboftargetok) {
 		$ret=`rm -fr $BUILDROOT/$PROJECT/documents`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/document`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/documents`;
-		# Removed known external modules to avoir any error when packaging on test env 
+
+		# Removed known external modules to avoid any error when packaging from env where external modules are tested 
+	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom/*`;	# For custom we want to keep dir
+		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/allscreens*`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/ancotec*`;
+	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/cabinetmed*`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/calling*`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/bootstrap*`;
-	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom*`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/factory*`;
+		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/lead*`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/management*`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/multicompany*`;
+		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/ndf*`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/nltechno*`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/oscim*`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/pos*`;
-		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/test`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/teclib*`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/timesheet*`;
-		# Removed other test files
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/oblyon*`;
+		# Removed other test files
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/eldy/*.new`;
+		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/api/explorer`;				# This is a dev tool
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/test`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/test`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/Thumbs.db $BUILDROOT/$PROJECT/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/*/Thumbs.db`;
@@ -511,6 +525,7 @@ if ($nboftargetok) {
 	    $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`;
+        $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/license.txt`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PDF`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PCLZip`;
@@ -702,7 +717,7 @@ if ($nboftargetok) {
 			use Date::Language;
 			$lang=Date::Language->new('English');
 			$datestring = $lang->time2str("%a %b %e %Y", time);
-    		$changelogstring="* ".$datestring." Laurent Destailleur $MAJOR.$MINOR.$REL1-$RPMSUBVERSION\n- Upstream release\n";
+    		$changelogstring="* ".$datestring." Laurent Destailleur (eldy) $MAJOR.$MINOR.$REL1-$RPMSUBVERSION\n- Upstream release\n";
 
 			print "Generate file $BUILDROOT/$BUILDFIC from $SOURCE/build/rpm/${BUILDFICSRC}\n";
 			open (SPECFROM,"<$SOURCE/build/rpm/${BUILDFICSRC}") || die "Error";
@@ -734,7 +749,7 @@ if ($nboftargetok) {
 			$ret=`$cmd`;
 			print "Move $RPMDIR/SOURCES/".$FILENAMETGZ2.".tgz into $NEWDESTI/".$FILENAMETGZ2.".tgz\n";
 			$cmd="mv \"$RPMDIR/SOURCES/".$FILENAMETGZ2.".tgz\" \"$NEWDESTI/".$FILENAMETGZ2.".tgz\"";
-			$ret=`$cmd`;
+			#$ret=`$cmd`;
 			next;
 		}
 
@@ -824,8 +839,17 @@ if ($nboftargetok) {
 			print "Create directory $BUILDROOT/$PROJECT.tmp/debian\n";
 			$ret=`mkdir "$BUILDROOT/$PROJECT.tmp/debian"`;
 			print "Copy $SOURCE/build/debian/xxx to $BUILDROOT/$PROJECT.tmp/debian\n";
+			# Add files for dpkg-source (changelog)
+			#$ret=`cp -f  "$SOURCE/build/debian/changelog"      "$BUILDROOT/$PROJECT.tmp/debian"`;
+			open (SPECFROM,"<$SOURCE/build/debian/changelog") || die "Error";
+			open (SPECTO,">$BUILDROOT/$PROJECT.tmp/debian/changelog") || die "Error";
+			while (<SPECFROM>) {
+				$_ =~ s/__VERSION__/$MAJOR.$MINOR.$newbuild/;
+				print SPECTO $_;
+			}
+			close SPECFROM;
+			close SPECTO;
 			# Add files for dpkg-source
-			$ret=`cp -f  "$SOURCE/build/debian/changelog"      "$BUILDROOT/$PROJECT.tmp/debian"`;
 			$ret=`cp -f  "$SOURCE/build/debian/compat"         "$BUILDROOT/$PROJECT.tmp/debian"`;
 			$ret=`cp -f  "$SOURCE/build/debian/control"        "$BUILDROOT/$PROJECT.tmp/debian"`;
 			$ret=`cp -f  "$SOURCE/build/debian/copyright"      "$BUILDROOT/$PROJECT.tmp/debian"`;
@@ -1004,7 +1028,7 @@ if ($nboftargetok) {
 			mkdir($DESTI.'/package_windows');
 			if (-d $DESTI.'/package_windows') { $NEWDESTI=$DESTI.'/package_windows'; } 
 
-     		print "Remove target $FILENAMEEXEDOLIWAMP.exe...\n";
+     		print "Remove target $NEWDESTI/$FILENAMEEXEDOLIWAMP.exe...\n";
     		unlink "$NEWDESTI/$FILENAMEEXEDOLIWAMP.exe";
  
  			print "Check that in your Wine setup, you create a Z: drive that point to your / directory.\n";
diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt
index 83836757ba7b120166231b754dbdba247fff44b1..2bf516dfe88b343b88a1e88dc8634ffcbc779db9 100644
--- a/build/makepack-howto.txt
+++ b/build/makepack-howto.txt
@@ -8,19 +8,20 @@ This files describe steps made by Dolibarr packaging team to make a
 beta version of Dolibarr, step by step.
 
 - Check all files are commited.
-- Update version/info in /ChangeLog
+- Update version/info in ChangeLog. 
+To generate a changelog of a major new version x.y.0, you can do "cd ~/git/dolibarr_x.y; git log `git rev-list --boundary x.y..origin/develop | grep ^- | cut -c2- | head -n`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
+To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
 - Update version number with x.y.z-w in htdocs/filefunc.inc.php
-- Update version number with x.y.z-w in build/debian/changelog
-- Update version number with x.y.z-w in build/exe/doliwamp/doliwamp.iss
 - Commit all changes.
-- Add a Tag (x.y.betaz_YYYYMMDD) and push it: git push --tags
-- Create a branch (x.y).
 
 - Run makepack-dolibarr.pl to generate all packages.
+
+- Create a branch (x.y), if version seems stable enough.
+
 - Move build files into www.dolibarr.org web site
   (/home/dolibarr/wwwroot/files/lastbuild).
 
-- Post a news on dolibarr.org/dolibarr.fr
+- Post a news on dolibarr.org/dolibarr.fr + social networks
 - Send mail on mailings-list
 
 
@@ -29,20 +30,22 @@ This files describe steps made by Dolibarr packaging team to make a
 complete release of Dolibarr, step by step.
 
 - Check all files are commited.
-- Update version/info in ChangeLog
+- Update version/info in ChangeLog. 
+To generate a changelog of a major new version x.y.0, you can do "cd ~/git/dolibarr_x.y; git log `git rev-list --boundary x.y..origin/develop | grep ^- | cut -c2- | head -n`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
+To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
 - Update version number with x.y.z in htdocs/filefunc.inc.php
-- Update version number with x.y.z in build/debian/changelog
-- Update version number with x.y.z in build/exe/doliwamp/doliwamp.iss
 - Commit all changes.
 
-- Build Dolibarr and DoliWamp packages with makepack-dolibarr.pl
+- Run makepack-dolibarr.pl to generate all packages.
+
 - Check content of built packages.
 - Move build files into www.dolibarr.org web site
   (/home/dolibarr/wwwroot/files/stable).
+
 - Run makepack-dolibarr.pl again with option to publish files on 
   sourceforge. This will also add official tag.
 - Edit symbolic links in directory "/home/dolibarr/wwwroot/files/stable/xxx"
   on server to point to new files (used by some web sites).
 
+- Post a news on dolibarr.org/dolibarr.fr + social networks
 - Send mail on mailings-list
-- Send news on OpenSource web sites (if major beta or release)
diff --git a/composer.json b/composer.json
index 4463efcfc749bcc97ba64e28c843c102db686438..622a307687dcfbe20270371df107c1628249d9ef 100644
--- a/composer.json
+++ b/composer.json
@@ -6,24 +6,32 @@
     "homepage": "http://www.dolibarr.org",
     "license": "GPL-3.0+",
     "support": {
-        "issues": "https://doliforge.org/projects/dolibarr",
+        "issues": "https://github.com/Dolibarr/dolibarr/issues",
         "forum": "http://www.dolibarr.org/forum",
-        "wiki": "http://wiki.dolibarr.org"
+        "wiki": "http://wiki.dolibarr.org",
+        "irc": "irc://chat.freenode.net/dolibarr",
+        "source": "https://github.com/Dolibarr/dolibarr"
     },
     "require": {
         "php": ">=5.3.0",
-        "ext-gd": "*",
         "ext-curl": "*"
     },
     "suggest": {
-        "ext-mysqli": "*",
-        "ext-pgsql": "*",
-        "ext-mssql": "*",
-        "ext-pdo_sqlite": "*",
-        "ext-imagick": "*",
-        "ext-mcrypt": "*",
-        "ext-openssl": "*",
-        "ext-mbstring": "*",
-        "ext-soap": "*"
+        "ext-mysqlnd": "To use with MySQL or MariaDB",
+        "ext-mysqli": "To use with MySQL or MariaDB",
+        "ext-pgsql": "To use with PostgreSQL",
+        "ext-mssql": "To use with MSSQL (experimental)",
+        "ext-pdo_sqlite": "To use with SQLite (experimental)",
+        "ext-gd": "Image manipulation (Required but maybe built-in PHP)",
+        "ext-imagick": "Image manipulation (TCPDF)",
+        "ext-mcrypt": "(Required but maybe built-in PHP)",
+        "ext-openssl": "Secure connections (Emails, SOAP…)",
+        "ext-mbstring": "Handle non UTF-8 databases",
+        "ext-soap": "Native SOAP",
+        "ext-zip": "ODT and Excel support",
+        "ext-xml": "Excel support"
+    },
+    "config": {
+        "vendor-dir": "htdocs/includes"
     }
 }
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 13c3586214e6ea14d2ff627df2cefc2bdd907c62..1220f69483e61637c84162f3f249f4fca920a016 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1426,13 +1426,13 @@ class Form
             foreach ($scrit as $crit)
             {
             	if ($i > 0) $sql.=" AND ";
-                $sql.="(p.ref LIKE '".$prefix.$crit."%' OR p.label LIKE '".$prefix.$crit."%'";
-                if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '".$prefix.$crit."%'";
+                $sql.="(p.ref LIKE '".$db->escape($prefix.$crit)."%' OR p.label LIKE '".$db->escape($prefix.$crit)."%'";
+                if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '".$db->escape($prefix.$crit)."%'";
                 $sql.=")";
                 $i++;
             }
             if (count($scrit) > 1) $sql.=")";
-          	if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$prefix.$filterkey."%'";
+          	if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$db->escape($prefix.$filterkey)."%'";
         	$sql.=')';
         }
         $sql.= $db->order("p.ref");
@@ -1777,7 +1777,7 @@ class Form
         $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid";
         $sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
         $sql.= " AND p.tobuy = 1";
-        if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype;
+        if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$this->db->escape($filtertype);
         if (! empty($filtre)) $sql.=" ".$filtre;
         // Add criteria on ref/label
         if ($filterkey != '')
@@ -1791,11 +1791,11 @@ class Form
         	foreach ($scrit as $crit)
         	{
         		if ($i > 0) $sql.=" AND ";
-        		$sql.="(pfp.ref_fourn LIKE '".$prefix.$crit."%' OR p.ref LIKE '".$prefix.$crit."%' OR p.label LIKE '".$prefix.$crit."%')";
+        		$sql.="(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%')";
         		$i++;
         	}
         	if (count($scrit) > 1) $sql.=")";
-        	if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$prefix.$filterkey."%'";
+        	if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
         	$sql.=')';
         }
         $sql.= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php
index 75ca19a35fed767da9556f3ea87fc01238741b71..d1784fb48636c3b62c8a6769c29488a92eef2aa0 100644
--- a/htdocs/filefunc.inc.php
+++ b/htdocs/filefunc.inc.php
@@ -29,7 +29,7 @@
  *  \brief      File that include conf.php file and commons lib like functions.lib.php
  */
 
-if (! defined('DOL_VERSION')) define('DOL_VERSION','3.6.5');
+if (! defined('DOL_VERSION')) define('DOL_VERSION','3.6.6');
 if (! defined('EURO')) define('EURO',chr(128));
 
 // Define syslog constants
diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php
index 61a1c3bff730bbace0a4646c6602e6042112a366..c8f78a11c42ae98e67be7ed4e9ffffd9c5a2d915 100644
--- a/htdocs/product/ajax/products.php
+++ b/htdocs/product/ajax/products.php
@@ -169,7 +169,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) {
 	
 	$match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET));
 	sort($match);
-	$idprod = (! empty($match [0]) ? $match [0] : '');
+	$idprod = (! empty($match[0]) ? $match[0] : '');
 	
 	if (! GETPOST($htmlname) && ! GETPOST($idprod))
 		return;
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 26d6577731801f8bc1b0ab82d16cfba6221cf5bf..0fc074e05d84d52f3f8660640c727c9e099684ce 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -2806,7 +2806,7 @@ class Product extends CommonObject
 	{
 		global $langs;
 		$langs->load('products');
-		if ($conf->productbatch->enabled) $langs->load("productbatch");
+		if (! empty($conf->productbatch->enabled)) $langs->load("productbatch");
 
 		if ($type == 2)
 		{