From f07c741176adc64e45bc075d0cb324e700c0776a Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Mon, 2 Jan 2017 11:31:21 +0100
Subject: [PATCH] Fix missing error message on invoice creation

---
 htdocs/compta/facture.php | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index eb8a7f4cfa4..91267578197 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1345,8 +1345,16 @@ if (empty($reshook))
 			setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
 			$error ++;
 		}
+        if (! GETPOST('prod_entry_mode'))
+        {
+            if (GETPOST('type') < 0 && ! GETPOST('search_idprod'))
+            {
+                setEventMessages($langs->trans('ErrorChooseBetweenFreeAntryOrPredefinedProduct'), null, 'errors');
+                $error ++;
+            }
+        }
 		if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) {
-			setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
+            setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
 			$error ++;
 		}
 		if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '') && $price_ht_devise == '') 	// Unit price can be 0 but not ''
-- 
GitLab