diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php
index b9a6ab1bc12dafb637f2fea6100f659ee840a06f..151bbdcabbe2771f70ba9069a0a3cbcbdf16738b 100644
--- a/htdocs/compta/fiche.php
+++ b/htdocs/compta/fiche.php
@@ -242,9 +242,10 @@ if ($socid > 0)
 
         print '<table class="noborder" width="100%">';
 
-        $sql = "SELECT s.nom, s.idp, f.rowid as facid, f.facnumber, f.amount, f.total, f.total_ttc,";
-        $sql.= " ".$db->pdate("f.datef")." as df, f.paye as paye, f.fk_statut as statut";
-		$sql.= ' ,sum(pf.amount) as am';
+        $sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,';
+        $sql.= ' '.$db->pdate("f.datef").' as df, f.paye as paye, f.fk_statut as statut,';
+		$sql.= ' s.nom, s.idp,';
+		$sql.= ' sum(pf.amount) as am';
         $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
 		$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
         $sql.= " WHERE f.fk_soc = s.idp AND s.idp = ".$societe->id;
@@ -270,7 +271,12 @@ if ($socid > 0)
                 $objp = $db->fetch_object($resql);
                 $var=!$var;
                 print "<tr $bc[$var]>";
-                print "<td><a href=\"../compta/facture.php?facid=$objp->facid\">".img_object($langs->trans("ShowBill"),"bill")." ".$objp->facnumber."</a></td>\n";
+                print '<td>';
+                $facturestatic->id=$objp->facid;
+                $facturestatic->ref=$objp->facnumber;
+                $facturestatic->type=$objp->type;
+                print $facturestatic->getNomUrl(1);
+                print '</td>';
                 if ($objp->df > 0)
                 {
                     print "<td align=\"right\">".dolibarr_print_date($objp->df)."</td>\n";
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index c3147eaf43fa2ec20ee5853146ebe3f7810377e2..cb763e658530721ff5990a2063b120b7f96f0293 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -1012,7 +1012,7 @@ class Facture extends CommonObject
 				}
 				
 				// Controle que facture source non deja remplacee par une autre
-				$idreplacement=$facreplaced->getIdReplacingInvoice();
+				$idreplacement=$facreplaced->getIdReplacingInvoice('validated');
 				if ($idreplacement && $idreplacement != $rowid)
 				{
 					$facreplacement=new Facture($this->db);
@@ -1791,14 +1791,20 @@ class Facture extends CommonObject
 	
 	/**
 	* 	\brief     	Renvoie l'id de la facture qui la remplace
-	*	\return		int		<0 si ko, 0 si aucune facture ne remplace, id facture sinon
+	*	\param		option		filtre sur statut ('', 'validated', ...)
+	*	\return		int			<0 si ko, 0 si aucune facture ne remplace, id facture sinon
 	*/
-	function getIdReplacingInvoice()
+	function getIdReplacingInvoice($option='')
 	{
 		$sql = 'SELECT rowid';
 		$sql.= ' FROM '.MAIN_DB_PREFIX.'facture';
 		$sql.= ' WHERE fk_facture_source = '.$this->id;
 		$sql.= ' AND type < 2';
+		if ($option == 'validated') $sql.= ' AND fk_statut = 1';
+		$sql.= ' ORDER BY fk_statut DESC';	// Au cas ou base corrompu et qu'il y a une
+											// facture de remplacement validee et une autre non
+											// on donne priorit� � la valid�e. Ne devrait pas arriver
+		
 		$resql=$this->db->query($sql);
 		if ($resql)
 		{