diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index a5992410f0b40df1c78a1594d797d8dfea6ad05c..8c02f1d7716fa48a0a531a0a3a92127f8179bfe8 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -771,7 +771,7 @@ if ($action == 'create')
     // Other attributes
     $parameters=array();
     $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-    if (empty($reshook))
+    if (empty($reshook) && ! empty($extrafields->attribute_label))
     {
         foreach($extrafields->attribute_label as $key=>$label)
         {
@@ -992,7 +992,7 @@ if ($action == 'edit')
 	// Other attributes
 	$parameters=array();
     $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-    if (empty($reshook))
+    if (empty($reshook) && ! empty($extrafields->attribute_label))
     {
     	foreach($extrafields->attribute_label as $key=>$label)
     	{
@@ -1304,7 +1304,7 @@ if ($rowid && $action != 'edit')
     // Other attributes
     $parameters=array();
     $reshook=$hookmanager->executeHooks('showOutputField',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-    if (empty($reshook))
+    if (empty($reshook) && ! empty($extrafields->attribute_label))
     {
         foreach($extrafields->attribute_label as $key=>$label)
         {
diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php
index 0f124265ee0315c04e5a372f4ba968ce2a7b7bb5..882262d6b58b7bcc28dbdaa46fdc48f17bd69b3c 100644
--- a/htdocs/comm/addpropal.php
+++ b/htdocs/comm/addpropal.php
@@ -243,7 +243,7 @@ if ($action == 'create')
 	// Other attributes
 	$parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"');
 	$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-	if (empty($reshook))
+	if (empty($reshook) && ! empty($extrafields->attribute_label))
 	{
 	    foreach($extrafields->attribute_label as $key=>$label)
 	    {
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 041fbadaead677b7124fde5e7e808f74573e9ce9..0a5e7437a1dcf35e00c3a6fb13655be4815a77e6 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -73,7 +73,7 @@ if (isset($socid))
 {
 	$objectid=$socid;
 	$module='societe';
-	$dbtable='';
+	$dbtable='&societe';
 }
 else if (isset($id) &&  $id > 0)
 {
@@ -1471,7 +1471,7 @@ if ($id > 0 || ! empty($ref))
     // Other attributes
     $parameters=array('colspan' => ' colspan="3"');
     $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-    if (empty($reshook))
+    if (empty($reshook) && ! empty($extrafields->attribute_label))
     {
         foreach($extrafields->attribute_label as $key=>$label)
         {
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 9854f2c8093440bf64939c34a6eb3de2aafa1460..169c24cb171b4ec47fd2d83e8bf90ed778af9663 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -2320,38 +2320,26 @@ class Commande extends CommonObject
         dol_syslog("Commande::delete sql=".$sql);
         if (! $this->db->query($sql) )
         {
-            dol_syslog("CustomerOrder::delete error", LOG_ERR);
+            dol_syslog(get_class($this)."::delete error", LOG_ERR);
             $error++;
         }
 
         // Delete order
         $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id;
-        dol_syslog("Commande::delete sql=".$sql);
+        dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
         if (! $this->db->query($sql) )
         {
-            dol_syslog("CustomerOrder::delete error", LOG_ERR);
+            dol_syslog(get_class($this)."::delete error", LOG_ERR);
             $error++;
         }
 
         // Delete linked object
-        // TODO deplacer dans le common
-        $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
-        $sql.= " WHERE fk_target = ".$this->id;
-        $sql.= " AND targettype = '".$this->element."'";
-        dol_syslog("Commande::delete sql=".$sql);
-        if (! $this->db->query($sql) )
-        {
-            dol_syslog("CustomerOrder::delete error", LOG_ERR);
-            $error++;
-        }
+        $res = $this->deleteObjectLinked();
+        if ($res < 0) $error++;
 
         // Delete linked contacts
         $res = $this->delete_linked_contact();
-        if ($res < 0)
-        {
-            dol_syslog("CustomerOrder::delete error", LOG_ERR);
-            $error++;
-        }
+        if ($res < 0) $error++;
 
         // On efface le repertoire de pdf provisoire
         $comref = dol_sanitizeFileName($this->ref);
@@ -2381,7 +2369,7 @@ class Commande extends CommonObject
             }
         }
 
-        if ($error == 0)
+        if (! $error)
         {
             // Appel des triggers
             include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 04edb4bcc1fc5903f38499828fa715aa67c6ffc7..e24946a17c7bc8293bd669daf8d396348c0a42ce 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1369,7 +1369,7 @@ if ($action == 'create' && $user->rights->commande->creer)
     // Other attributes
     $parameters=array('colspan' => ' colspan="3"');
     $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-    if (empty($reshook))
+    if (empty($reshook) && ! empty($extrafields->attribute_label))
     {
         foreach($extrafields->attribute_label as $key=>$label)
         {
@@ -1921,7 +1921,7 @@ else
             // Other attributes
             $parameters=array('colspan' => ' colspan="2"');
             $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-            if (empty($reshook))
+            if (empty($reshook) && ! empty($extrafields->attribute_label))
             {
                 foreach($extrafields->attribute_label as $key=>$label)
                 {
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 36c3b49cb60fdc00ef777d2bd079efd31e9507c4..80803d6d71452e0d28af1cc5d7c85eed4173ec1d 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -179,7 +179,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes')
             if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
             {
                 $ret=$object->fetch($id);    // Reload to get new records
-                $result=facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
+                $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
             }
             if ($result >= 0)
             {
@@ -360,7 +360,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->v
             if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
             {
                 $ret=$object->fetch($id);    // Reload to get new records
-                facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
+                facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
             }
         }
         else
@@ -437,7 +437,7 @@ if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS
 	        if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
 	        {
                 $ret=$object->fetch($id);    // Reload to get new records
-	            facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
+	            facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
 	        }
 	    }
     }
@@ -1098,7 +1098,7 @@ if (($action == 'addline' || $action == 'addline_predef') && $user->rights->fact
         if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
         {
             $ret=$object->fetch($id);    // Reload to get new records
-            facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
+            facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
         }
         unset($_POST['qty']);
         unset($_POST['type']);
@@ -1200,7 +1200,7 @@ if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save']
         if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
         {
             $ret=$object->fetch($id);    // Reload to get new records
-            facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
+            facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
         }
     }
 }
@@ -1229,7 +1229,7 @@ if ($action == 'up' && $user->rights->facture->creer)
         $outputlangs = new Translate("",$conf);
         $outputlangs->setDefaultLang($newlang);
     }
-    if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
+    if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
 
     Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']);
     exit;
@@ -1251,7 +1251,7 @@ if ($action == 'down' && $user->rights->facture->creer)
         $outputlangs = new Translate("",$conf);
         $outputlangs->setDefaultLang($newlang);
     }
-    if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
+    if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
 
     Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']);
     exit;
@@ -1485,7 +1485,7 @@ if (GETPOST('action') == 'builddoc')	// En get ou en post
         $outputlangs = new Translate("",$conf);
         $outputlangs->setDefaultLang($newlang);
     }
-    $result=facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
+    $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
     if ($result <= 0)
     {
         dol_print_error($db,$result);
@@ -1804,7 +1804,7 @@ if ($action == 'create')
     // Other attributes
     $parameters=array('colspan' => ' colspan="3"');
     $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-    if (empty($reshook))
+    if (empty($reshook) && ! empty($extrafields->attribute_label))
     {
         foreach($extrafields->attribute_label as $key=>$label)
         {
@@ -2713,7 +2713,7 @@ else
             // Other attributes
             $parameters=array('colspan' => ' colspan="3"');
             $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-            if (empty($reshook))
+            if (empty($reshook) && ! empty($extrafields->attribute_label))
             {
                 foreach($extrafields->attribute_label as $key=>$label)
                 {
@@ -3057,7 +3057,7 @@ else
                         $outputlangs = new Translate("",$conf);
                         $outputlangs->setDefaultLang($newlang);
                     }
-                    $result=facture_pdf_create($db, $object, '', $_REQUEST['model'], $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
+                    $result=facture_pdf_create($db, $object, $_REQUEST['model'], $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
                     if ($result <= 0)
                     {
                         dol_print_error($db,$result);
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index ad5624f8a3f16b53f33a874e45e4bd6d8da53786..04ece4813c1437ed81a49d2739e70e357b43c7ad 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1130,12 +1130,12 @@ class Facture extends CommonObject
 
         $error=0;
         $this->db->begin();
+        
+        // Delete linked object
+        $res = $this->deleteObjectLinked();
+        if ($res < 0) $error++;
 
-        $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
-        $sql.= " WHERE fk_target = ".$rowid;
-        $sql.= " AND targettype = '".$this->element."'";
-
-        if ($this->db->query($sql))
+        if (! $error)
         {
         	// If invoice was converted into a discount not yet consumed, we remove discount
             $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except';
@@ -1188,7 +1188,7 @@ class Facture extends CommonObject
                 }
                 else
                 {
-                    $this->error=$this->db->error()." sql=".$sql;
+                    $this->error=$this->db->lasterror()." sql=".$sql;
                     dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
                     $this->db->rollback();
                     return -6;
@@ -1196,7 +1196,7 @@ class Facture extends CommonObject
             }
             else
             {
-                $this->error=$this->db->error()." sql=".$sql;
+                $this->error=$this->db->lasterror()." sql=".$sql;
                 dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
                 $this->db->rollback();
                 return -4;
@@ -1204,7 +1204,7 @@ class Facture extends CommonObject
         }
         else
         {
-            $this->error=$this->db->error()." sql=".$sql;
+            $this->error=$this->db->lasterror();
             dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
             $this->db->rollback();
             return -2;
diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php
index 0fd3e8863547eb5dce4aa88272664fccc7a94d1c..e4af98742aeee1e3a5e319ca18fffb7e597d77e3 100644
--- a/htdocs/compta/paiement/fiche.php
+++ b/htdocs/compta/paiement/fiche.php
@@ -112,7 +112,7 @@ if ($action == 'confirm_valide' && GETPOST('confirm') == 'yes' && $user->rights-
 				$outputlangs = new Translate("",$conf);
 				$outputlangs->setDefaultLang($_REQUEST['lang_id']);
 			}
-			if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs, $hookmanager);
+			if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager);
 		}
 
 		Header('Location: fiche.php?id='.$paiement->id);
diff --git a/htdocs/compta/payment_sc/fiche.php b/htdocs/compta/payment_sc/fiche.php
index ab14d509a850c9c316cbb47167e3743ac60aec81..d9bee27e91a8a9b031921d6bb2dafe66f3d3791c 100644
--- a/htdocs/compta/payment_sc/fiche.php
+++ b/htdocs/compta/payment_sc/fiche.php
@@ -94,7 +94,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' &&
 				$outputlangs = new Translate("",$conf);
 				$outputlangs->setDefaultLang($_REQUEST['lang_id']);
 			}
-			if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs, $hookmanager);
+			if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager);
 		}
 
 		Header('Location: fiche.php?id='.$paiement->id);
diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php
index e1462e6dd1a14a105cdb364465a88a1409faa728..0c1434a4fd8fd3ed1002e6cb5d51f492b4b1e861 100644
--- a/htdocs/core/ajax/saveinplace.php
+++ b/htdocs/core/ajax/saveinplace.php
@@ -1,5 +1,5 @@
 <?php
-/* Copyright (C) 2011 Regis Houssin  <regis@dolibarr.fr>
+/* Copyright (C) 2011-2012 Regis Houssin  <regis@dolibarr.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -134,6 +134,14 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
 		if (! $error)
 		{
 			if (! is_object($object)) $object = new GenericObject($db);
+
+			// Specific for add_object_linked()
+			// TODO add a function for variable treatment
+			$object->ext_fk_element = $newvalue;
+			$object->ext_element = $ext_element;
+			$object->fk_element = $fk_element;
+			$object->element = $element;
+			
 			$ret=$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format);
 			if ($ret > 0)
 			{
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 4465d79aa06eb6d0a060df529e0a175f836aa14b..cf9c09b70d6b9ded28e3a5e4e3ad448ed86bb804 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -294,7 +294,7 @@ abstract class CommonObject
         $sql.= " WHERE element_id =".$this->id;
         $sql.= " AND fk_c_type_contact IN (".$listId.")";
 
-        dol_syslog(get_class($this)."::delete_linked_contact sql=".$sql);
+        dol_syslog(get_class($this)."::delete_linked_contact sql=".$sql, LOG_DEBUG);
         if ($this->db->query($sql))
         {
             return 1;
@@ -1514,10 +1514,10 @@ abstract class CommonObject
         if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $justsource=true;
         if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $justtarget=true;
 
-        $sourceid = (! empty($sourceid) ? $sourceid : $this->id );
-        $targetid = (! empty($targetid) ? $targetid : $this->id );
-        $sourcetype = (! empty($sourcetype) ? $sourcetype : (! empty($this->origin) ? $this->origin : $this->element ) );
-        $targettype = (! empty($targettype) ? $targettype : $this->element );
+        $sourceid = (! empty($sourceid) ? $sourceid : $this->id);
+        $targetid = (! empty($targetid) ? $targetid : $this->id);
+        $sourcetype = (! empty($sourcetype) ? $sourcetype : (! empty($this->origin) ? $this->origin : $this->element));
+        $targettype = (! empty($targettype) ? $targettype : $this->element);
 
         // Links beetween objects are stored in this table
         $sql = 'SELECT fk_source, sourcetype, fk_target, targettype';
@@ -1629,7 +1629,77 @@ abstract class CommonObject
             dol_print_error($this->db);
         }
     }
-
+    
+    /**
+     *	Update object linked of a current object
+     * 
+     *	@param	int		$sourceid		Object source id
+     *	@param  string	$sourcetype		Object source type
+     *	@param  int		$targetid		Object target id
+     *	@param  string	$targettype		Object target type
+     *	@return							int	>0 if OK, <0 if KO
+     */
+    function updateObjectLinked($sourceid='', $sourcetype='', $targetid='', $targettype='')
+    {
+    	$updatesource=false;
+    	$updatetarget=false;
+    	
+    	if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $updatesource=true;
+    	else if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $updatetarget=true;
+    	
+    	$sql = "UPDATE ".MAIN_DB_PREFIX."element_element SET ";
+    	if ($updatesource)
+    	{
+    		$sql.= "fk_source = ".$sourceid;
+    		$sql.= ", sourcetype = '".$sourcetype."'";
+    		$sql.= " WHERE fk_target = ".$this->id;
+    		$sql.= " AND targettype = '".$this->element."'";
+    	}
+    	else if ($updatetarget)
+    	{
+    		$sql.= "fk_target = ".$targetid;
+    		$sql.= ", targettype = '".$targettype."'";
+    		$sql.= " WHERE fk_source = ".$this->id;
+    		$sql.= " AND sourcetype = '".$this->element."'";
+    	}
+    
+    	dol_syslog(get_class($this)."::updateObjectLinked sql=".$sql, LOG_DEBUG);
+    	if ($this->db->query($sql))
+    	{
+    		return 1;
+    	}
+    	else
+    	{
+    		$this->error=$this->db->lasterror();
+    		dol_syslog(get_class($this)."::updateObjectLinked error=".$this->error, LOG_ERR);
+    		return -1;
+    	}
+    }
+    
+	/**
+	 *	Delete all links between an object $this
+	 *
+	 *	@return     int	>0 if OK, <0 if KO
+	 */
+	function deleteObjectLinked()
+	{
+		$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
+		$sql.= " WHERE fk_target = ".$this->id;
+		$sql.= " AND targettype = '".$this->element."'";
+		
+		dol_syslog(get_class($this)."::deleteObjectLinked sql=".$sql, LOG_DEBUG);
+		if ($this->db->query($sql))
+		{
+			return 1;
+		}
+		else
+		{
+			$this->error=$this->db->lasterror();
+			dol_syslog(get_class($this)."::deleteObjectLinked error=".$this->error, LOG_ERR);
+			return -1;
+		}
+	}
+    
     /**
      *      Set statut of an object
      *
@@ -1787,6 +1857,8 @@ abstract class CommonObject
     {
         global $langs;
 
+		$error=0;
+		
         if (count($this->array_options) > 0)
         {
             // Check parameters
@@ -2045,19 +2117,19 @@ abstract class CommonObject
             if ($objecttype == 'facture')          {
                 $tplpath = 'compta/'.$element;
             }
-            if ($objecttype == 'propal')           {
+            else if ($objecttype == 'propal')           {
                 $tplpath = 'comm/'.$element;
             }
-            if ($objecttype == 'shipping')         {
+            else if ($objecttype == 'shipping')         {
                 $tplpath = 'expedition';
             }
-            if ($objecttype == 'delivery')         {
+            else if ($objecttype == 'delivery')         {
                 $tplpath = 'livraison';
             }
-            if ($objecttype == 'invoice_supplier') {
+            else if ($objecttype == 'invoice_supplier') {
                 $tplpath = 'fourn/facture';
             }
-            if ($objecttype == 'order_supplier')   {
+            else if ($objecttype == 'order_supplier')   {
                 $tplpath = 'fourn/commande';
             }
 
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index 3babbc8aeeeb1cb0d1ec21a3286f495612086a78..9acad8b746626e8cc8de66a29bafc12cfc4006f1 100755
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -148,7 +148,7 @@ class HookManager
                 	$var=!$var;
 
                     // Hooks that return int
-                    if (($method == 'doActions' || $method='formObjectOptions') && method_exists($actioninstance,$method))
+                    if (($method == 'doActions' || $method == 'formObjectOptions') && method_exists($actioninstance,$method))
                     {
                         $resaction+=$actioninstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
                         if ($resaction < 0 || ! empty($actioninstance->error) || (! empty($actioninstance->errors) && count($actioninstance->errors) > 0))
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index bf81c7ceaadec87544df89adb80e9b396c35e76c..d85bbcef9dc5fd4c0dc1a1ccfcf4b708afa8b7da 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1,10 +1,10 @@
 <?php
 /* Copyright (c) 2002-2007 Rodolphe Quiedeville  <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2011 Laurent Destailleur   <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2012 Laurent Destailleur   <eldy@users.sourceforge.net>
  * Copyright (C) 2004      Benoit Mortier        <benoit.mortier@opensides.be>
  * Copyright (C) 2004      Sebastien Di Cintio   <sdicintio@ressource-toi.org>
  * Copyright (C) 2004      Eric Seigne           <eric.seigne@ryxeo.com>
- * Copyright (C) 2005-2011 Regis Houssin         <regis@dolibarr.fr>
+ * Copyright (C) 2005-2012 Regis Houssin         <regis@dolibarr.fr>
  * Copyright (C) 2006      Andre Cianfarani      <acianfa@free.fr>
  * Copyright (C) 2006      Marc Barilley/Ocebo   <marc@ocebo.com>
  * Copyright (C) 2007      Franky Van Liedekerke <franky.van.liedekerker@telenet.be>
@@ -87,7 +87,6 @@ class Form
 			if ($perm)
 			{
 				$tmp=explode(':',$typeofdata);
-				if (preg_match('/^(string|email|numeric)$/i',$tmp[0])) $tmp[0] = 'text';
 				$ret.= '<div class="editkey_'.$tmp[0].'" id="'.$htmlname.'">';
 				$ret.= $langs->trans($text);
 				$ret.= '</div>'."\n";
@@ -237,8 +236,7 @@ class Form
 			if (preg_match('/^(string|email|numeric)/',$inputType))
 			{
 				$tmp=explode(':',$inputType);
-				$inputType='text';
-				$inputOption=$tmp[1];
+				$inputType=$tmp[0]; $inputOption=$tmp[1];
 				if (! empty($tmp[2])) $savemethod=$tmp[2];
 			}
 			if (preg_match('/^datepicker/',$inputType))
diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js
index 32ef01985a9f57e6cf9bdbc501b09a114651d7bc..ca3d3bacab8785db7f6871a79525adc261d392e4 100644
--- a/htdocs/core/js/editinplace.js
+++ b/htdocs/core/js/editinplace.js
@@ -107,7 +107,7 @@ $(document).ready(function() {
 		$( '#val_' + $(this).attr('id') ).click();
 	});
 	
-	$('.editval_text').editable(urlSaveInPlace, {
+	$('.editval_string').editable(urlSaveInPlace, {
 		type		: 'text',
 		id			: 'field',
 		width		: 300,
@@ -118,7 +118,7 @@ $(document).ready(function() {
 		indicator	: indicatorInPlace,
 		submitdata	: function(result, settings) {
 			var htmlname = $(this).attr('id').substr(4);
-			return getParameters('text', htmlname);
+			return getParameters('string', htmlname);
 		},
 		callback : function(result, settings) {
 			var obj = $.parseJSON(result);
@@ -131,7 +131,7 @@ $(document).ready(function() {
 			}
 		}
 	});
-	$('.editkey_text').hover(
+	$('.editkey_string').hover(
 			function () {
 				$( '#val_' + $(this).attr('id') ).addClass("editval_hover");
 			},
@@ -139,7 +139,7 @@ $(document).ready(function() {
 				$( '#val_' + $(this).attr('id') ).removeClass("editval_hover");
 			}
 	);
-	$('.editkey_text').click(function() {
+	$('.editkey_string').click(function() {
 		$( '#val_' + $(this).attr('id') ).click();
 	});
 	
@@ -236,7 +236,7 @@ $(document).ready(function() {
 		},
 		callback : function(result, settings) {
 			var obj = $.parseJSON(result);
-			
+
 			if (obj.error) {
 				$(this).html(this.revert);
 				$.jnotify(obj.error, "error", true);
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index c587cecffa143700a69cdb348c2c695a2519fa0e..b6dc024b0e3e49dfe149841612966fa54975342f 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -1050,7 +1050,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
 
         if ($usealternatemethod || $gm)	// Si time gm, seule adodb peut convertir
         {
-            $date=adodb_mktime($hour,$minute,$second,$month,$day,$year,$isdst,$gm);
+            $date=adodb_mktime($hour,$minute,$second,$month,$day,$year,0,$gm);
         }
         else
         {
diff --git a/htdocs/core/modules/cheque/pdf/modules_chequereceipts.php b/htdocs/core/modules/cheque/pdf/modules_chequereceipts.php
index 9a3fa4c68c8583c69c5665be724b9098febeb007..668e64bf43165087321ef6a4fd643c5a7a35e1a0 100644
--- a/htdocs/core/modules/cheque/pdf/modules_chequereceipts.php
+++ b/htdocs/core/modules/cheque/pdf/modules_chequereceipts.php
@@ -112,7 +112,7 @@ function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
 		else
 		{
 			$outputlangs->charset_output=$sav_charset_output;
-			dol_print_error($db,"facture_pdf_create Error: ".$obj->error);
+			dol_print_error($db,"chequereceipt_pdf_create Error: ".$obj->error);
 			return -1;
 		}
 
diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php
index f0a282725adbfe505a115f1a5c956cf341daadd5..62d8f11411a85fb449d279c2c4235315ec1c39e4 100644
--- a/htdocs/core/modules/commande/modules_commande.php
+++ b/htdocs/core/modules/commande/modules_commande.php
@@ -205,7 +205,7 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0
 		require_once($file);
 
 		$obj = new $classname($db);
-		$obj->message = $message;
+		//$obj->message = $message;
 
 		// We save charset_output to restore it because write_file can change it if needed for
 		// output format that does not support UTF8.
diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php
index a87a2ed7016b53524776b5ec16ff53a568056845..a6e5d6ae38fc88653a15da22b65297c26b3f2dcf 100644
--- a/htdocs/core/modules/facture/modules_facture.php
+++ b/htdocs/core/modules/facture/modules_facture.php
@@ -130,12 +130,11 @@ abstract class ModeleNumRefFactures
 
 
 /**
- *  Create a document onto disk accordign to template module.
+ *  Create a document onto disk according to template module.
  *
  *	@param   	DoliDB		$db  			Database handler
  *	@param   	Object		$object			Object invoice
- *	@param	    string		$message		message
- *	@param	    string		$modele			Force le modele a utiliser ('' to not force)
+ *	@param	    string		$modele			Force template to use ('' to not force)
  *	@param		Translate	$outputlangs	objet lang a utiliser pour traduction
  *  @param      int			$hidedetails    Hide details of lines
  *  @param      int			$hidedesc       Hide description
@@ -143,7 +142,7 @@ abstract class ModeleNumRefFactures
  *  @param      HookManager	$hookmanager	Hook manager instance
  *	@return  	int        					<0 if KO, >0 if OK
  */
-function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
+function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
 {
 	global $conf,$user,$langs;
 
@@ -204,7 +203,6 @@ function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hide
 		require_once($file);
 
 		$obj = new $classname($db);
-		$obj->message = $message;
 
 		// We save charset_output to restore it because write_file can change it if needed for
 		// output format that does not support UTF8.
diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php
index dfc6c2322f05c26fbb0c828c3405b2638c162d17..68887d575434701abd556530c4b0e3053463fc6d 100644
--- a/htdocs/core/modules/modWorkflow.class.php
+++ b/htdocs/core/modules/modWorkflow.class.php
@@ -155,7 +155,7 @@ class modWorkflow extends DolibarrModules
 
 		$sql = array();
 
-        return $this->_init($sql,$option);
+        return $this->_init($sql,$options);
     }
 
     /**
diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php
index ab9c6f09dd3288f418bf24fff8e6b020f60ca485..2ab268c6d9e71a7ff87db728b1010b1d996b1c6e 100644
--- a/htdocs/core/modules/propale/modules_propale.php
+++ b/htdocs/core/modules/propale/modules_propale.php
@@ -195,7 +195,7 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
 		require_once($file);
 
 		$obj = new $classname($db);
-		$obj->message = $message;
+		//$obj->message = $message;
 
 		// We save charset_output to restore it because write_file can change it if needed for
 		// output format that does not support UTF8.
diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
index a45a2d8b9581aec6b363b89d3b90f2990d4ed45c..11d0cddffe52c16410ca845497e43495da5d95e3 100755
--- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
+++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
@@ -58,38 +58,69 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator
  *
  *	@param	    DoliDB		$db  			objet base de donnee
  *	@param	    Object		$object			object supplier invoice
- *	@param	    string		$model			force le modele a utiliser ('' to not force)
+ *	@param	    string		$modele			Force template to use ('' to not force)
  *	@param		Translate	$outputlangs	objet lang a utiliser pour traduction
  *  @return     int         				0 if KO, 1 if OK
  */
-function supplier_invoice_pdf_create($db, $object, $model, $outputlangs)
+function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs)
 {
-	global $conf, $langs;
+	global $conf, $user, $langs;
 
 	$langs->load("suppliers");
 
-	$dir = DOL_DOCUMENT_ROOT."/core/modules/supplier_invoice/pdf/";
+	$error=0;
+	
+	// Increase limit for PDF build
+    $err=error_reporting();
+    error_reporting(0);
+    @set_time_limit(120);
+    error_reporting($err);
+	
+	$dir = "/core/modules/supplier_invoice/";
+    $srctemplatepath='';
 
 	// Positionne modele sur le nom du modele de invoice fournisseur a utiliser
-	if (! dol_strlen($model))
+	if (! dol_strlen($modele))
 	{
 		if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF))
 		{
-			$model = $conf->global->INVOICE_SUPPLIER_ADDON_PDF;
+			$modele = $conf->global->INVOICE_SUPPLIER_ADDON_PDF;
 		}
 		else
 		{
-		    $model = 'canelle';
-			//print $langs->trans("Error")." ".$langs->trans("Error_INVOICE_SUPPLIER_ADDON_PDF_NotDefined");
-			//return 0;
+		    $modele = 'canelle';
 		}
 	}
+	
+    // If selected modele is a filename template (then $modele="modelname:filename")
+	$tmp=explode(':',$modele,2);
+    if (! empty($tmp[1]))
+    {
+        $modele=$tmp[0];
+        $srctemplatepath=$tmp[1];
+    }
+    	
+	// Search template file
+	$file=''; $classname=''; $filefound=0;
+	foreach(array('doc','pdf') as $prefix)
+	{
+        $file = $prefix."_".$modele.".modules.php";
+
+        // On verifie l'emplacement du modele
+        $file = dol_buildpath($dir.'pdf/'.$file);	// TODO rename into doc/
+
+        if (file_exists($file))
+	    {
+	        $filefound=1;
+	        $classname=$prefix.'_'.$modele;
+	        break;
+	    }
+	}
+
 	// Charge le modele
-	$file = "pdf_".$model.".modules.php";
-	if (file_exists($dir.$file))
+	if ($filefound)
 	{
-		$classname = "pdf_".$model;
-		require_once($dir.$file);
+		require_once($file);
 
 		$obj = new $classname($db,$object);
 
@@ -103,6 +134,14 @@ function supplier_invoice_pdf_create($db, $object, $model, $outputlangs)
 			// we delete preview files
         	require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
 			dol_delete_preview($object);
+			
+			// Appel des triggers
+			include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+			$interface=new Interfaces($db);
+			$result=$interface->run_triggers('BILL_BUILDDOC',$object,$user,$langs,$conf);
+			if ($result < 0) { $error++; $this->errors=$interface->errors; }
+			// Fin appel triggers
+			
 			return 1;
 		}
 		else
@@ -115,7 +154,7 @@ function supplier_invoice_pdf_create($db, $object, $model, $outputlangs)
 	}
 	else
 	{
-		print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file);
+		print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file);
 		return 0;
 	}
 }
diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
index 62f182c6ab8efb1eb16f49a93cae0fab77c8f745..adab34b9e5ac88eb82c19618e34a3b82fd9b5882 100755
--- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
@@ -303,6 +303,24 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 
 					$nexY+=2;    // Passe espace entre les lignes
 
+					// Cherche nombre de lignes a venir pour savoir si place suffisante
+					if ($i < ($nblignes - 1) && empty($hidedesc))	// If it's not last line
+					{
+						//on recupere la description du produit suivant
+						$follow_descproduitservice = $object->lines[$i+1]->desc;
+						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
+						$nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4;
+						// Et si on affiche dates de validite, on ajoute encore une ligne
+						if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
+						{
+							$nblineFollowDesc += 4;
+						}
+					}
+					else	// If it's last line
+					{
+						$nblineFollowDesc = 0;
+					}
+
 					// Test if a new page is required
 					if ($pagenb == 1)
 					{
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index e9fd3cfbd76d749baec4f6f00163356647633578..73295740d16cf7710798894c1c8e21cd7962c863 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -761,16 +761,16 @@ class Expedition extends CommonObject
 
 		if ( $this->db->query($sql) )
 		{
-			$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
-			$sql.= " WHERE fk_target = ".$this->id;
-			$sql.= " AND targettype = '".$this->element."'";
+			// Delete linked object
+			$res = $this->deleteObjectLinked();
+			if ($res < 0) $error++;
 
-			if ( $this->db->query($sql) )
+			if (! $error)
 			{
 				$sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition";
 				$sql.= " WHERE rowid = ".$this->id;
 
-				if ( $this->db->query($sql) )
+				if ($this->db->query($sql))
 				{
 					$this->db->commit();
 
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index ca3eb2cbbb13cd59d9b38c842acbba199b76c9b8..b72df22e2de678007f2942630cf26a84756ef178 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -585,16 +585,8 @@ class Fichinter extends CommonObject
 		$this->db->begin();
 
 		// Delete linked object
-		$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
-		$sql.= " WHERE fk_target = ".$this->id;
-		$sql.= " AND targettype = '".$this->element."'";
-		dol_syslog("Fichinter::delete sql=".$sql);
-		if (! $this->db->query($sql) )
-		{
-			dol_syslog("Fichinter::delete error", LOG_ERR);
-			$this->error=$this->db->lasterror();
-			$error++;
-		}
+        $res = $this->deleteObjectLinked();
+        if ($res < 0) $error++;
 
 		// Delete linked contacts
 		$res = $this->delete_linked_contact();
diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php
index 72d1822e746c5934faafc2856cda7cfa8d405876..5d41bca48f42e677aefbe2382b87042bfa6683b9 100644
--- a/htdocs/livraison/class/livraison.class.php
+++ b/htdocs/livraison/class/livraison.class.php
@@ -549,15 +549,18 @@ class Livraison extends CommonObject
 	{
         require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
 		$this->db->begin();
+		
+		$error=0;
 
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraisondet";
 		$sql.= " WHERE fk_livraison = ".$this->id;
-		if ( $this->db->query($sql) )
+		if ($this->db->query($sql))
 		{
-			$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
-			$sql.= " WHERE fk_target = ".$this->id;
-			$sql.= " AND targettype = '".$this->element."'";
-			if ( $this->db->query($sql) )
+			// Delete linked object
+			$res = $this->deleteObjectLinked();
+			if ($res < 0) $error++;
+			
+			if (! $error)
 			{
 				$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraison";
 				$sql.= " WHERE rowid = ".$this->id;
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 70a549c8df8b1674aa3020686edee3b1b2c45ab2..3fa8d523db999a6c00fa3e3548ffa20bc02bec20 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -783,7 +783,7 @@ else
         // Other attributes
         $parameters=array('colspan' => ' colspan="2"');
         $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-        if (empty($reshook))
+        if (empty($reshook) && ! empty($extrafields->attribute_label))
         {
             foreach($extrafields->attribute_label as $key=>$label)
             {
@@ -987,7 +987,7 @@ else
             // Other attributes
             $parameters=array('colspan' => ' colspan="2"');
             $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-            if (empty($reshook))
+            if (empty($reshook) && ! empty($extrafields->attribute_label))
             {
                 foreach($extrafields->attribute_label as $key=>$label)
                 {
@@ -1214,7 +1214,7 @@ else
             // Other attributes
             $parameters=array('colspan' => ' colspan="2"');
             $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-            if (empty($reshook))
+            if (empty($reshook) && ! empty($extrafields->attribute_label))
             {
                 foreach($extrafields->attribute_label as $key=>$label)
                 {
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 3fd17d21210122af0688f47c3bd9e6fef80c8e87..3fe4af14642d336f149be2e58b1bd5f8abba8902 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -941,7 +941,7 @@ else
         // Other attributes
         $parameters=array('colspan' => ' colspan="3"');
         $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-        if (empty($reshook))
+        if (empty($reshook) && ! empty($extrafields->attribute_label))
         {
             foreach($extrafields->attribute_label as $key=>$label)
             {
@@ -1369,7 +1369,7 @@ else
             // Other attributes
             $parameters=array('colspan' => ' colspan="3"');
             $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-            if (empty($reshook))
+            if (empty($reshook) && ! empty($extrafields->attribute_label))
             {
                 foreach($extrafields->attribute_label as $key=>$label)
                 {
@@ -1718,7 +1718,7 @@ else
         // Other attributes
         $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"');
         $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-        if (empty($reshook))
+        if (empty($reshook) && ! empty($extrafields->attribute_label))
         {
             foreach($extrafields->attribute_label as $key=>$label)
             {
diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php
index 246418765ba301f4e2c78d2b5d9c44c4bf68661b..8691787cc49f1f79f54c90505788ea78035b0918 100644
--- a/htdocs/theme/auguria/style.css.php
+++ b/htdocs/theme/auguria/style.css.php
@@ -1652,7 +1652,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
 /*  jQuery - jeditable                                                            */
 /* ============================================================================== */
 
-.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select {
+.editkey_textarea, .editkey_ckeditor, .editkey_string, .editkey_email, .editkey_numeric, .editkey_select {
 	background: url(<?php echo dol_buildpath($path.'/theme/auguria/img/edit.png',1) ?>) right top no-repeat;
 	cursor: pointer;
 }
@@ -1662,7 +1662,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
 	cursor: pointer;
 }
 
-.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
+.editval_textarea:hover, .editval_ckeditor:hover, .editval_string:hover, .editval_email:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
 	background: white;
 	cursor: pointer;
 }
diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php
index be308f8e78bee26ba947b886e0116b33b0bc9d80..f67bb97d284437fe5dccaa6c27bbbbab0edca9e0 100644
--- a/htdocs/theme/bureau2crea/style.css.php
+++ b/htdocs/theme/bureau2crea/style.css.php
@@ -1844,7 +1844,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
 /*  jQuery - jeditable                                                            */
 /* ============================================================================== */
 
-.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select {
+.editkey_textarea, .editkey_ckeditor, .editkey_string, .editkey_email, .editkey_numeric, .editkey_select {
 	background: url(<?php echo dol_buildpath($path.'/theme/bureau2crea/img/edit.png',1) ?>) right top no-repeat;
 	cursor: pointer;
 }
@@ -1854,7 +1854,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
 	cursor: pointer;
 }
 
-.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
+.editval_textarea:hover, .editval_ckeditor:hover, .editval_string:hover, .editval_email:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
 	background: white;
 	cursor: pointer;
 }
diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php
index 98c0d473af2ff9be3730106dcc8f44c51d3b3843..4452da5ba02c59b289cf9f8c5b5fdb544a7426f2 100644
--- a/htdocs/theme/cameleo/style.css.php
+++ b/htdocs/theme/cameleo/style.css.php
@@ -1791,7 +1791,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
 /*  jQuery - jeditable                                                            */
 /* ============================================================================== */
 
-.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select {
+.editkey_textarea, .editkey_ckeditor, .editkey_string, .editkey_email, .editkey_numeric, .editkey_select {
 	background: url(<?php echo dol_buildpath($path.'/theme/cameleo/img/edit.png',1) ?>) right top no-repeat;
 	cursor: pointer;
 }
@@ -1801,7 +1801,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
 	cursor: pointer;
 }
 
-.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
+.editval_textarea:hover, .editval_ckeditor:hover, .editval_string:hover, .editval_email:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
 	background: white;
 	cursor: pointer;
 }
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index aa38c527c0a7d26826b989d3333fb289ca8502d3..d6f6a06e630895d2cfd4a9c9956f9ba0a843257e 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -1,8 +1,8 @@
 <?php
-/* Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C)      2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2007-2011 Regis Houssin        <regis@dolibarr.fr>
- * Copyright (C)	  2011 Philippe Grand       <philippe.grand@atoo-net.com>
+/* Copyright (C) 2004-2012	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2006		Rodolphe Quiedeville	<rodolphe@quiedeville.org>
+ * Copyright (C) 2007-2012	Regis Houssin			<regis@dolibarr.fr>
+ * Copyright (C) 2011		Philippe Grand			<philippe.grand@atoo-net.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1959,7 +1959,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
 /*  jQuery - jeditable                                                            */
 /* ============================================================================== */
 
-.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select {
+.editkey_textarea, .editkey_ckeditor, .editkey_string, .editkey_email, .editkey_numeric, .editkey_select {
 	background: url(<?php echo dol_buildpath($path.'/theme/eldy/img/edit.png',1) ?>) right top no-repeat;
 	cursor: pointer;
 }
@@ -1969,7 +1969,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
 	cursor: pointer;
 }
 
-.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
+.editval_textarea:hover, .editval_ckeditor:hover, .editval_string:hover, .editval_email:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
 	background: white;
 	cursor: pointer;
 }
diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php
index 4f0dc72bf2ea1b00a952f03b0e2f55223cdfc906..c6487d262f7141cb95f39f5e3d985e709b1b4ca5 100644
--- a/scripts/invoices/rebuild_merge_pdf.php
+++ b/scripts/invoices/rebuild_merge_pdf.php
@@ -270,7 +270,7 @@ if ( $resql=$db->query($sql) )
 					}
 				}
             	print "Build PDF for invoice ".$obj->facnumber." - Lang = ".$outputlangs->defaultlang."\n";
-				$result=facture_pdf_create($db, $fac, '', $newmodel?$newmodel:$fac->modelpdf, $outputlangs);
+				$result=facture_pdf_create($db, $fac, $newmodel?$newmodel:$fac->modelpdf, $outputlangs);
 
 				// Add file into files array
 				$files[] = $conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf';
diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php
index c3c490ef4e1b8f9109ff88201941de3754538328..b0977142f33dde58f72abc0a329dd7018735141b 100644
--- a/test/phpunit/BuildDocTest.php
+++ b/test/phpunit/BuildDocTest.php
@@ -162,14 +162,14 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
 
     	// Crabe
     	$localobject->modelpdf='crabe';
-    	$result=facture_pdf_create($db, $localobject, '', $localobject->modelpdf, $langs);
+    	$result=facture_pdf_create($db, $localobject, $localobject->modelpdf, $langs);
 
     	$this->assertLessThan($result, 0);
     	print __METHOD__." result=".$result."\n";
 
     	// Oursin
     	$localobject->modelpdf='oursin';
-    	$result=facture_pdf_create($db, $localobject, '', $localobject->modelpdf, $langs);
+    	$result=facture_pdf_create($db, $localobject, $localobject->modelpdf, $langs);
 
     	$this->assertLessThan($result, 0);
     	print __METHOD__." result=".$result."\n";