diff --git a/htdocs/core/commonobject.class.php b/htdocs/core/commonobject.class.php
index 55312cd20cd..447d82fd6ae 100644
--- a/htdocs/core/commonobject.class.php
+++ b/htdocs/core/commonobject.class.php
@@ -417,7 +417,7 @@ class CommonObject
// TODO uniformise code
if ($object == 'shipping') $object = 'expedition';
if ($object == 'delivery') $object = 'livraison';
-
+
$class = ucfirst($object);
$this->$object = new $class($this->db);
$this->$object->fetch($this->origin_id);
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 545645ccda3..d8d58f60040 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -600,9 +600,12 @@ else
print '
'.$mesg.'
';
}
- $typeobject = $expedition->origin;
- $origin = $expedition->origin;
- $expedition->fetch_object();
+ if (!empty($expedition->origin))
+ {
+ $typeobject = $expedition->origin;
+ $origin = $expedition->origin;
+ $expedition->fetch_object();
+ }
if (strlen($expedition->tracking_number))
{
@@ -958,7 +961,7 @@ else
print '';
- if ($expedition->$origin->id)
+ if (!empty($origin) && $expedition->$origin->id)
{
print '
';
//show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id);
diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php
index f453bf09a59..0004b81d803 100644
--- a/htdocs/livraison/fiche.php
+++ b/htdocs/livraison/fiche.php
@@ -28,6 +28,7 @@
*/
require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/livraison/livraison.class.php");
require_once(DOL_DOCUMENT_ROOT."/includes/modules/livraison/modules_livraison.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/sendings.lib.php");