From 7c75d98f9a6666211238e67b491ed0049f68c6e5 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sat, 29 Oct 2016 18:43:12 +0200
Subject: [PATCH] FIX #5866

---
 htdocs/compta/facture/list.php           | 4 ++++
 htdocs/product/stock/productlot_list.php | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 3f5f7183e90..79342baf293 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -229,6 +229,10 @@ if (empty($reshook))
 	    $error++;
 	}
 	
+	if (! $error && $massaction == 'confirm_presend' && GETPOST('modelselected'))  // If we change the template, we must not send email, but keep on send email form
+	{
+	    $massaction='presend';
+	}
 	if (! $error && $massaction == 'confirm_presend')
 	{
 		$resaction = '';
diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php
index 2d01c95520b..0b0b1510ada 100644
--- a/htdocs/product/stock/productlot_list.php
+++ b/htdocs/product/stock/productlot_list.php
@@ -145,7 +145,7 @@ if (($id > 0 || ! empty($ref)) && $action != 'add')
  */
 
 if (GETPOST('cancel')) { $action='list'; $massaction=''; }
-if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
+if (! GETPOST('confirmmassaction') && $massaction != 'confirm_presend') { $massaction=''; }
 
 $parameters=array();
 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
-- 
GitLab