diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index 2c69b643884effd5f40c0a0582914ec4241de914..34535b1d321e792ae5ec10c1548a847c105b9808 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -6,7 +6,7 @@
  * Copyright (C) 2004		Eric Seigne				<eric.seigne@ryxeo.com>
  * Copyright (C) 2005-2012	Regis Houssin			<regis.houssin@capnetworks.com>
  * Copyright (C) 2011-2012	Juanjo Menent			<jmenent@2byte.es>
- * Copyright (C) 2011-2012	Philippe Grand			<philippe.grand@atoo-net.com>
+ * Copyright (C) 2011-2013	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
@@ -65,9 +65,9 @@ if ($action == 'updateMask')
 	if (isset($res))
 	{
 		if ($res < 0)
-			setEventMessage($langs->trans("Error"), 'errors');
-		else
 			setEventMessage($langs->trans("SetupSaved"));
+		else
+			setEventMessage($langs->trans("Error"), 'errors');
 	}
 }
 
@@ -77,9 +77,9 @@ else if ($action == 'set_SHIPPING_FREE_TEXT')
 	$res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
 
 	if ($res < 0)
-		setEventMessage($langs->trans("Error"), 'errors');
-	else
 		setEventMessage($langs->trans("SetupSaved"));
+	else
+		setEventMessage($langs->trans("Error"), 'errors');
 }
 
 else if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
@@ -88,9 +88,9 @@ else if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
 	$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
 
 	if ($res < 0)
-		setEventMessage($langs->trans("Error"), 'errors');
-	else
 		setEventMessage($langs->trans("SetupSaved"));
+	else
+		setEventMessage($langs->trans("Error"), 'errors');
 }
 
 else if ($action == 'specimen')
@@ -173,12 +173,7 @@ else if ($action == 'setdoc')
 
 else if ($action == 'setmodel')
 {
-	$res = dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
-	
-	if ($res < 0)
-		setEventMessage($langs->trans("Error"), 'errors');
-	else
-		setEventMessage($langs->trans("SetupSaved"));
+	dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
 }
 
 
@@ -225,9 +220,8 @@ if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON))
 dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
 
 /*
- * Numbering module
- */
-//print "<br>";
+ * Expedition numbering model
+ */ 
 
 print_titre($langs->trans("SendingsNumberingModules"));
 
@@ -259,16 +253,16 @@ foreach ($dirmodels as $reldir)
 				{
 					$file = substr($file, 0, dol_strlen($file)-4);
 
-					require_once DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.'.php';
+					require_once $dir.$file.'.php';
 
 					$module = new $file;
-
-					// Show modules according to features level
-					if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
-					if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
-
+					
 					if ($module->isEnabled())
 					{
+						// Show modules according to features level
+						if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+						if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
+					
 						$var=!$var;
 						print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n";
 						print '<td>';
@@ -278,7 +272,9 @@ foreach ($dirmodels as $reldir)
                         // Show example of numbering module
                         print '<td nowrap="nowrap">';
                         $tmp=$module->getExample();
-                        if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
+                        if (preg_match('/^Error/',$tmp)) { 
+							$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; 
+						}
                         elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
                         else print $tmp;
                         print '</td>'."\n";
@@ -333,7 +329,7 @@ print '</table><br>';
 
 
 /*
- *  Modeles de documents
+ *  Documents models for Sendings Receipt
  */
 print_titre($langs->trans("SendingsReceiptModel"));
 
@@ -495,4 +491,4 @@ print '</table>';
 
 llxFooter();
 $db->close();
-?>
+?>
\ No newline at end of file
diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php
index fa4b7b3c1d40edc0408846ed9f4941e7e8dc98f8..49cbeee902633144c365b5da7c44def23446b527 100644
--- a/htdocs/admin/livraison.php
+++ b/htdocs/admin/livraison.php
@@ -6,7 +6,7 @@
  * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
  * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
  * Copyright (C) 2011-2012 Juanjo Menent        <jmenent@2byte.es>
- * Copyright (C) 2011-2012 Philippe Grand       <philippe.grand@atoo-net.com>
+ * Copyright (C) 2011-2013 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
@@ -164,7 +164,7 @@ if ($action == 'setmod')
     // TODO Verifier si module numerotation choisi peut etre active
     // par appel methode canBeActivated
 
-    dolibarr_set_const($db, "LIVRAISON_ADDON",$value,'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "LIVRAISON_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
 }
 
 
@@ -209,8 +209,9 @@ $h++;
 dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
 
 /*
- *  Module numerotation
+ * Livraison numbering model
  */
+ 
 print_titre($langs->trans("DeliveryOrderNumberingModules"));
 
 print '<table class="noborder" width="100%">';
@@ -240,16 +241,16 @@ foreach ($dirmodels as $reldir)
                 {
                     $file = substr($file, 0, dol_strlen($file)-4);
 
-                    require_once DOL_DOCUMENT_ROOT ."/core/modules/livraison/".$file.'.php';
+                    require_once $dir.$file.'.php';
 
                     $module = new $file;
-
-                    // Show modules according to features level
-                    if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
-                    if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
-
-                    if ($module->isEnabled())
+					
+					if ($module->isEnabled())
                     {
+						// Show modules according to features level
+						if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+						if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
+                    
                         $var=!$var;
                         print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
                         print $module->info();
@@ -258,13 +259,15 @@ foreach ($dirmodels as $reldir)
                         // Show example of numbering module
                         print '<td nowrap="nowrap">';
                         $tmp=$module->getExample();
-                        if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
+                        if (preg_match('/^Error/',$tmp)) { 
+							$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; 
+						}
                         elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
                         else print $tmp;
                         print '</td>'."\n";
 
                         print '<td align="center">';
-                        if ($conf->global->LIVRAISON_ADDON == "$file")
+                        if ($conf->global->LIVRAISON_ADDON_NUMBER == "$file")
                         {
                             print img_picto($langs->trans("Activated"),'switch_on');
                         }
@@ -311,12 +314,12 @@ print '</table>';
 
 
 /*
- *  Modeles de documents
+ *  Documents Models for delivery
  */
 print '<br>';
 print_titre($langs->trans("DeliveryOrderModel"));
 
-// Defini tableau def de modele invoice
+// Defini tableau def de modele 
 $type="delivery";
 $def = array();
 
@@ -397,7 +400,7 @@ foreach ($dirmodels as $reldir)
                         print "</td>";
                     }
 
-                    // Defaut
+                    // Default
                     print "<td align=\"center\">";
                     if ($conf->global->LIVRAISON_ADDON_PDF == "$name")
                     {
diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php
index aa609d65721b46584a1d51116efefde746ed1da8..ab8569b15b0497ec026509dd5775aca8d92d8ef7 100644
--- a/htdocs/admin/supplier_order.php
+++ b/htdocs/admin/supplier_order.php
@@ -54,9 +54,9 @@ $specimenthirdparty->initAsSpecimen();
 if ($action == 'updateMask')
 {
     $maskconstorder=GETPOST('maskconstorder','alpha');
-    $maskorder=GETPOST('maskorder','alpha');
+    $maskvalue=GETPOST('maskvalue','alpha');
 
-    if ($maskconstorder)  $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity);
+    if ($maskconstorder)  $res = dolibarr_set_const($db,$maskconstorder,$maskvalue,'chaine',0,'',$conf->entity);
 
     if (! $res > 0) $error++;
 
@@ -70,7 +70,7 @@ if ($action == 'updateMask')
     }
 }
 
-if ($action == 'specimen')  // For orders
+else if ($action == 'specimen')  // For orders
 {
     $modele=GETPOST('module','alpha');
 
@@ -116,88 +116,54 @@ if ($action == 'specimen')  // For orders
     }
 }
 
-if ($action == 'set')
+// Activate a model
+else if ($action == 'set')
 {
-	$label = GETPOST('label','alpha');
-	$scandir = GETPOST('scandir','alpha');
-
-    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
-    $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
-    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
-    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
-    $sql.= ")";
-    $res=$db->query($sql);
-    if ($res)
-    {
-
-    }
-    //	else dol_print_error($db);
+	$ret = addDocumentModel($value, $type, $label, $scandir);
 }
 
-if ($action == 'del')
+else if ($action == 'del')
 {
-    $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
-    $sql.= " WHERE nom = '".$value."'";
-    $sql.= " AND type = '".$type."'";
-    $sql.= " AND entity = ".$conf->entity;
-    $db->query($sql);
-    if ($res)
-    {
-
-    }
-    //    else dol_print_error($db);
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+        if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_SUPPLIER_ADDON_PDF',$conf->entity);
+	}
 }
 
-if ($action == 'setdoc')
+// Set default model
+else if ($action == 'setdoc')
 {
-	$label = GETPOST('label','alpha');
-	$scandir = GETPOST('scandir','alpha');
-
-    $db->begin();
-
-    if ($type == 'order_supplier' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
-    {
-        $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
-    }
-
-    // On active le modele
-    $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
-    $sql_del.= " WHERE nom = '".$db->escape($value)."'";
-    $sql_del.= " AND type = '".$type."'";
-    $sql_del.= " AND entity = ".$conf->entity;
-    $result1=$db->query($sql_del);
-
-    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
-    $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
-    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
-    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
-    $sql.= ")";
-    $result2=$db->query($sql);
-    if ($result1 && $result2)
-    {
-        $db->commit();
-    }
-    else
-    {
-        $db->rollback();
-    }
+	if (dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
+	{
+		// La constante qui a ete lue en avant du nouveau set
+		// on passe donc par une variable pour avoir un affichage coherent
+		$conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
+	}
+
+	// On active le modele
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+		$ret = addDocumentModel($value, $type, $label, $scandir);
+	}
 }
 
-if ($action == 'setmod')
+else if ($action == 'setmod')
 {
     // TODO Verifier si module numerotation choisi peut etre active
     // par appel methode canBeActivated
 
-    dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON",$value,'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
 }
 
-if ($action == 'addcat')
+else if ($action == 'addcat')
 {
     $fourn = new Fournisseur($db);
     $fourn->CreateCategory($user,$_POST["cat"]);
 }
 
-if ($action == 'set_SUPPLIER_ORDER_FREE_TEXT')
+else if ($action == 'set_SUPPLIER_ORDER_FREE_TEXT')
 {
     $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT');	// No alpha here, we want exact string
 
@@ -306,7 +272,7 @@ foreach ($dirmodels as $reldir)
                         print '</td>'."\n";
 
                         print '<td align="center">';
-                        if ($conf->global->COMMANDE_SUPPLIER_ADDON == "$file")
+                        if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER == "$file")
                         {
                             print img_picto($langs->trans("Activated"),'switch_on');
                         }
@@ -352,10 +318,8 @@ foreach ($dirmodels as $reldir)
 print '</table><br>';
 
 
-
-
 /*
- * Modeles documents for supplier orders
+ *  Documents models for supplier orders
  */
 
 print_titre($langs->trans("OrdersModelModule"));
@@ -396,17 +360,14 @@ print '</tr>'."\n";
 
 clearstatcache();
 
+$var=true;
 foreach ($dirmodels as $reldir)
 {
 	$dir = dol_buildpath($reldir."core/modules/supplier_order/pdf/");
 
     if (is_dir($dir))
     {
-        $var=true;
-
         $handle=opendir($dir);
-
-
         if (is_resource($handle))
         {
             while (($file = readdir($handle))!==false)
@@ -448,7 +409,7 @@ foreach ($dirmodels as $reldir)
                         print "</td>";
                     }
 
-                    // Defaut
+                    // Default
                     print '<td align="center">';
                     if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name")
                     {
@@ -485,6 +446,12 @@ foreach ($dirmodels as $reldir)
 }
 
 print '</table><br/>';
+print '<br>';
+
+/*
+ * Other options
+ *
+ */
 
 print_titre($langs->trans("OtherOptions"));
 print '<table class="noborder" width="100%">';
diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php
index 112173656c54da5646563c27648658daea9021c8..5704f96d0cc5c1ee9120cafa814dbb983c8d1010 100644
--- a/htdocs/core/modules/modExpedition.class.php
+++ b/htdocs/core/modules/modExpedition.class.php
@@ -3,6 +3,7 @@
  * Copyright (C) 2004-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2011 Regis Houssin        <regis.houssin@capnetworks.com>
  * Copyright (C) 2011      Juanjo Menent	    <jmenent@2byte.es>
+ * Copyright (C) 2013	   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
@@ -101,7 +102,7 @@ class modExpedition extends DolibarrModules
 		$this->const[$r][4] = 0;
 		$r++;
 
-		$this->const[$r][0] = "LIVRAISON_ADDON";
+		$this->const[$r][0] = "LIVRAISON_ADDON_NUMBER";
 		$this->const[$r][1] = "chaine";
 		$this->const[$r][2] = "mod_livraison_jade";
 		$this->const[$r][3] = 'Nom du gestionnaire de numerotation des bons de reception';
diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php
index 7ca64a2c524ea8c62bfb46b708b4664af9480e13..5868d6d21087afadac7f27389061013333fb1437 100644
--- a/htdocs/core/modules/modFournisseur.class.php
+++ b/htdocs/core/modules/modFournisseur.class.php
@@ -3,6 +3,7 @@
  * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
  * Copyright (C) 2012      Juanjo Menent		<jmenent@2byte.es>
+ * Copyright (C) 2013	   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
@@ -81,21 +82,29 @@ class modFournisseur extends DolibarrModules
             $this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF";
             $this->const[$r][1] = "chaine";
             $this->const[$r][2] = "muscadet";
+			$this->const[$r][3] = 'Nom du gestionnaire de generation des bons de commande en PDF';
+			$this->const[$r][4] = 0;
 			$r++;
 
-            $this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON";
+            $this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_NUMBER";
             $this->const[$r][1] = "chaine";
             $this->const[$r][2] = "mod_commande_fournisseur_muguet";
+			$this->const[$r][3] = 'Nom du gestionnaire de numerotation des commandes fournisseur';
+			$this->const[$r][4] = 0;
 			$r++;
 
 			$this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_PDF";
             $this->const[$r][1] = "chaine";
             $this->const[$r][2] = "canelle";
+			$this->const[$r][3] = 'Nom du gestionnaire de generation des factures fournisseur en PDF';
+			$this->const[$r][4] = 0;
 			$r++;
 			
 			$this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_NUMBER";
             $this->const[$r][1] = "chaine";
-            $this->const[$r][2] = "tulip";
+            $this->const[$r][2] = "mod_facture_fournisseur_tulip";
+			$this->const[$r][3] = 'Nom du gestionnaire de numerotation des factures fournisseur';
+			$this->const[$r][4] = 0;
 			$r++;
 
             // Boxes
diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php
index f753d8b2fcee1d3dc03d8baac5b69d1417b60ca6..7e1febf318921ae000b1ebd3560626140704b941 100644
--- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php
+++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php
@@ -20,11 +20,11 @@
 
 /**
  *    	\file       htdocs/core/modules/supplier_order/mod_facture_fournisseur_cactus.php
- *		\ingroup    commande
+ *		\ingroup    supplier invoice
  *		\brief      File containing the Cactus Class of numbering models of suppliers invoices references
  */
 
-require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/modules_facturefournisseur.php';
+require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/modules_facturefournisseur.php';
 
 
 /**
@@ -123,7 +123,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
 
 		//$date=time();
         $date=$object->datec;   // Not always defined
-        if (empty($date)) $date=$object->date;  // Creation date is order date for suppliers orders
+        if (empty($date)) $date=$object->date;  // Creation date is invoice date for suppliers invoices
         $yymm = strftime("%y%m",$date);
         $num = sprintf("%04s",$max+1);
 
diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php
index 72cf50adc6061b2034c86af3a24ae35237ea3d63..d0ee9e23738b02125b12e5e0164c75e6997b9c60 100644
--- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php
+++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php
@@ -123,7 +123,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices
 			return 0;
 		}
 
-		$numFinal=get_next_value($db,$mask,'facture_fournisseur','ref','',$objsoc->code_fournisseur,$object->date_commande);
+		$numFinal=get_next_value($db,$mask,'facture_fournisseur','ref','',$objsoc->code_fournisseur,$object->datec);
 
 		return  $numFinal;
 	}
diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
index 7a80cc93bfebf91017638725879be18bb6114c87..6be7100c14ec2037c8b0cfb0e8671d4bd28dc070 100755
--- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
+++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
@@ -22,6 +22,7 @@
  *		\file       htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
  *      \ingroup    facture fournisseur
  *      \brief      File that contains parent class for supplier invoices models
+ *					and parent class for supplier invoices numbering models
  */
 require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';	// requis car utilise par les classes qui heritent
@@ -36,7 +37,7 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator
 
 
 	/**
-	 *  Return list of active generation modules
+	 *  Return list of active generation models
 	 *
      *  @param	DoliDB	$db     			Database handler
      *  @param  string	$maxfilenamelength  Max length of value to show
@@ -131,7 +132,7 @@ abstract class ModeleNumRefSuppliersInvoices
 }
 
 /**
- *	Create a document onto disk according to template module.
+ *	Create a document onto disk according to template model.
  *
  *	@param	    DoliDB		$db  			Database handler
  *	@param	    Object		$object			Object supplier invoice
@@ -158,7 +159,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided
 
     $srctemplatepath='';
 
-	// Positionne le modele sur le nom du modele a utiliser
+	// Set the model on the model name to use
 	if (! dol_strlen($modele))
 	{
 		if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF))
@@ -189,7 +190,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided
 		{
 			$file = $prefix."_".$modele.".modules.php";
 
-			// On verifie l'emplacement du modele
+			// We checked the location of the model
 			$file=dol_buildpath($reldir."core/modules/supplier_invoice/pdf/".$file,0);
 			if (file_exists($file))
 			{
@@ -201,7 +202,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided
 		if ($filefound) break;
 	}
 
-	// Charge le modele
+	// Load the model
 	if ($filefound)
 	{
 		require_once $file;
@@ -219,12 +220,12 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided
         	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 			dol_delete_preview($object);
 
-			// Appel des triggers
+			// Calls triggers
 			include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
 			$interface=new Interfaces($db);
 			$result=$interface->run_triggers('BILL_INVOICE_BUILDDOC',$object,$user,$langs,$conf);
 			if ($result < 0) { $error++; $this->errors=$interface->errors; }
-			// Fin appel triggers
+			// End calls triggers
 
 			return 1;
 		}
@@ -238,7 +239,14 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided
 	}
 	else
 	{
-		print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file);
+		if (! $conf->global->INVOICE_SUPPLIER_ADDON_PDF)
+		{
+			print $langs->trans("Error")." ".$langs->trans("Error_INVOICE_SUPPLIER_ADDON_PDF_NotDefined");
+		}
+		else
+		{
+			print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file);
+		}
 		return 0;
 	}
 }
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index ffc123fe2de15c4cde84dbf1bd1d2131da17251d..cd106c3a1201cbb987f0b23b5c21660c3d6af3cd 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -1305,6 +1305,59 @@ class FactureFournisseur extends CommonInvoice
         $result.=$lien.($max?dol_trunc($this->ref,$max):$this->ref).$lienfin;
         return $result;
     }
+	
+	 /**
+     *  Renvoie la reference de facture suivante non utilisee en fonction du modele
+     *                  de numerotation actif defini dans INVOICE_SUPPLIER_ADDON_NUMBER
+     *
+     *  @param	    Societe		$soc  		objet societe
+     *  @return     string                  reference libre pour la facture
+     */
+    function getNextNumRef($soc)
+    {
+        global $db, $langs, $conf;
+        $langs->load("orders");
+
+        $dir = DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/';
+
+        if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER))
+        {
+            $file = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER.'.php';
+
+            if (is_readable($dir.'/'.$file))
+            {
+                // Definition du nom de modele de numerotation de commande fournisseur
+                $modName=$conf->global->INVOICE_SUPPLIER_ADDON_NUMBER;
+                require_once $dir.'/'.$file;
+
+                // Recuperation de la nouvelle reference
+                $objMod = new $modName($this->db);
+
+                $numref = "";
+                $numref = $objMod->invoice_get_num($soc,$this);
+
+                if ( $numref != "")
+                {
+                    return $numref;
+                }
+                else
+                {
+                    dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error);
+                    return -1;
+                }
+            }
+            else
+            {
+                print $langs->trans("Error")." ".$langs->trans("Error_FailedToLoad_INVOICE_SUPPLIER_ADDON_NUMBER_File",$conf->global->INVOICE_SUPPLIER_ADDON_NUMBER);
+                return -2;
+            }
+        }
+        else
+        {
+            print $langs->trans("Error")." ".$langs->trans("Error_INVOICE_SUPPLIER_ADDON_NUMBER_NotDefined");
+            return -3;
+        }
+    }
 
 
     /**