diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 61f51b19436af51729c459210bf196e4ee85e35f..b938bdd0883a7b64154f053b8a26b7fbf1de75b1 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -424,7 +424,7 @@ class Facture extends CommonInvoice
 				    else                                // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
 				    {
 				        $origin_id = $tmp_origin_id;
-    					$ret = $this->add_object_linked($origin, $origin_id);
+    					$ret = $this->add_object_linked($this->origin, $origin_id);
     					if (! $ret)
     					{
     						dol_print_error($this->db);
@@ -434,7 +434,7 @@ class Facture extends CommonInvoice
 				    
 					if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN))
 					{
-    					$originforcontact = $origin;
+    					$originforcontact = $this->origin;
     					$originidforcontact = $origin_id;
     					if ($originforcontact == 'shipping')     // shipment and order share the same contacts. If creating from shipment we take data of order
     					{