diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 9bd2d022ace..316983a5d0a 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -1939,7 +1939,7 @@ class Contrat extends CommonObject
if ($user->rights->contrat->lire) {
$label = ''.$langs->trans("ShowContract").'';
- $label .= '
'.$langs->trans('Ref').': '.$this->ref;
+ $label .= '
'.$langs->trans('Ref').': '.($this->ref?$this->ref:$this->id);
$label .= '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client);
$label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier;
if (!empty($this->total_ht)) {
@@ -1971,7 +1971,7 @@ class Contrat extends CommonObject
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
- if ($withpicto != 2) $result.= $this->ref;
+ if ($withpicto != 2) $result.= ($this->ref?$this->ref:$this->id);
$result .= $linkend;
return $result;