diff --git a/ChangeLog b/ChangeLog
index 0291eeb3a21dec5d9a6b3342bec8c7a9ec7f7bce..f83979aa8e085ce31b839c75f9bae145657b0190 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
English Dolibarr ChangeLog
--------------------------------------------------------------
+***** ChangeLog for 3.6.4 compared to 3.6.3 *****
+- Fix: [ bug #2893 ] Dolibarr error when viewing an invoice after changing invoice mask
+
***** ChangeLog for 3.6.3 compared to 3.6.2 *****
- Fix: ref_ext was not saved when recording a customer order from web service
- Fix: amarok is a bugged theme making dolidroid failed. We switch to eldy automatically with dolidroid.
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index f5a7c27ecd1a5407dc20321f1c547b4d76447fda..72103f6ac5ae44c917f5d27059981ac5779c1da5 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -2558,15 +2558,16 @@ class Facture extends CommonInvoice
$numref = "";
$numref = $obj->getNextValue($soc,$this,$mode);
- if ($numref != "")
- {
- return $numref;
- }
- else
- {
+ /**
+ * $numref can be empty in case we ask for the last value because if there is no invoice created with the
+ * set up mask.
+ */
+ if ($mode != 'last' && !$numref) {
dol_print_error($db,"Facture::getNextNumRef ".$obj->error);
return "";
}
+
+ return $numref;
}
else
{