diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php
index 6aee7991effc449103735fb81472e43ab0262ce1..1fb20e82694303cc2c2b297fc2602f8de6dde6e5 100644
--- a/htdocs/actioncomm.class.php
+++ b/htdocs/actioncomm.class.php
@@ -27,6 +27,8 @@
         \version    $Revision$
 */
 
+require_once(DOL_DOCUMENT_ROOT.'/cactioncomm.class.php');
+
 
 /**     \class      ActionComm
 	    \brief      Classe permettant la gestion des actions commerciales
@@ -34,12 +36,14 @@
 
 class ActionComm
 {
-    var $id;
     var $db;
+    var $error;
     
     var $type_id;
     var $type_code;
     var $type;
+	
+    var $id;
     var $label;
     var $datec;			// Date creation enregistrement (datec)
     var $datem;			// Date modif enregistrement (tms)
@@ -53,7 +57,6 @@ class ActionComm
     var $contact;
     var $note;
     var $percent;
-    var $error;
     
     /**
      *      \brief      Constructeur
@@ -82,6 +85,31 @@ class ActionComm
         if (! $this->percent)  $this->percent = 0;
         if (! $this->priority) $this->priority = 0;
         
+		$this->db->begin();
+
+		if (! $this->type_id && $this->type_code)
+		{
+			# Get id from code
+			$cactioncomm=new CActionComm($this->db);
+			$result=$cactioncomm->fetch($this->type_code);
+			if ($result)
+			{
+				$this->type_id=$cactioncomm->id;
+			}
+			else
+			{
+				$this->error=$cactioncomm->error;
+				$this->db->rollback();
+				return -1;
+			}
+		}
+		
+		if (! $this->type_id)
+		{
+			$this->error="ErrorWrongParameters";
+			return -1;
+		}
+		
         $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm";
         $sql.= "(datec,";
         if ($this->datep) $sql.= "datep,";
@@ -111,12 +139,13 @@ class ActionComm
             $result=$interface->run_triggers('ACTION_CREATE',$this,$author,$langs,$conf);
             // Fin appel triggers
     
+			$this->db->commit();
             return $this->id;
         }
         else
         {
-			$this->error=$this->db->error();
-            dolibarr_print_error($this->db);
+			$this->error=$this->db->lasterror().' sql='.$sql;
+			$this->db->rollback();
             return -1;
         }
     
@@ -135,7 +164,7 @@ class ActionComm
 		$sql.= " ".$this->db->pdate("a.datec")." as datec, tms as datem,";
 		$sql.= " a.note, a.label, a.fk_action as type_id,";
 		$sql.= " fk_soc, fk_user_author, fk_contact, fk_facture, a.percent, a.fk_commande,";
-		$sql.= " c.id as type_id, c.code, c.libelle";
+		$sql.= " c.id as type_id, c.code as type_code, c.libelle";
 		$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c";
 		$sql.= " WHERE a.id=".$id." AND a.fk_action=c.id";
 	
@@ -150,7 +179,7 @@ class ActionComm
 	
 				$this->id        = $obj->id;
 				$this->type_id   = $obj->type_id;
-				$this->type_code = $obj->code;
+				$this->type_code = $obj->type_code;
 				$transcode=$langs->trans("Action".$obj->code);
 				$type_libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle);
 				$this->type = $type_libelle;
diff --git a/htdocs/cactioncomm.class.php b/htdocs/cactioncomm.class.php
index 6945a780714b1c9d060ca3f443e36183fb07ec35..58eff125f55a561419ac8bc95030043e6a268d65 100644
--- a/htdocs/cactioncomm.class.php
+++ b/htdocs/cactioncomm.class.php
@@ -33,7 +33,7 @@
 	    \brief      Classe permettant la gestion des diff�rents types d'actions commerciales
 */
 
-class CActioncomm {
+class CActionComm {
   var $db;
 
   var $id;
@@ -52,7 +52,7 @@ class CActioncomm {
    *    \brief      Constructeur
    *    \param      DB          Handler d'acc�s base de donn�e
    */
-  function CActioncomm($DB)
+  function CActionComm($DB)
     {
       $this->db = $DB;
     }
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index ce793b0d962da4b7c1dbefa28cd98b60f5c3b95a..46a4a6a8faef923fb3e7575ead984a8d47f2a61a 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -961,7 +961,7 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
 						$subject = $langs->trans('Bill').' '.$fac->ref;
 					}
 
-					$actiontypeid=9;
+					$actiontypecode='AC_FAC';
 					$actionmsg ='Mail envoy� par '.$from.' � '.$sendto.'.<br>';
 
 					if ($message)
@@ -975,7 +975,7 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
 				if ($_POST['action'] == 'relance')
 				{
 					$subject = 'Relance facture '.$fac->ref;
-					$actiontypeid=10;
+					$actiontypecode='AC_FAC';
 					$actionmsg='Mail envoy� par '.$from.' � '.$sendto.'.<br>';
 					if ($message) {
 						$actionmsg.='Texte utilis� dans le corps du message:<br>';
@@ -1011,7 +1011,7 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
 						require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
 						require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php');
 						$actioncomm = new ActionComm($db);
-						$actioncomm->type_id     = $actiontypeid;
+						$actioncomm->type_code   = $actiontypecode;
 						$actioncomm->label       = $actionmsg2;
 						$actioncomm->note        = $actionmsg;
 						$actioncomm->date        = time();	// L'action est faite maintenant
diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php
index 0ed40caf5374795a8cd963078ca0c2aca29c5d08..6ad2e54c24ef0cdaf4176ef6576244a4f7c7918d 100644
--- a/htdocs/compta/fiche.php
+++ b/htdocs/compta/fiche.php
@@ -662,7 +662,8 @@ if ($socid > 0)
             print "</tr>\n";
             $i++;
         }
-        $db->free();
+
+        $db->free($result);
     }
     else
     {