From 4c3f9d6d5e1b5f86cfbe2cf2016e626b6387f580 Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 18 May 2018 15:20:16 +0200 Subject: [PATCH] FIX : test is_erasable() must be done before call function delete() too to avoid delete invoice with &action=delete in url --- htdocs/compta/facture/card.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d79b8d0bae5..9d5cc64c2a4 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -186,13 +186,17 @@ if (empty($reshook)) $qualified_for_stock_change = $object->hasProductsOrServices(1); } - $result = $object->delete($user, 0, $idwarehouse); - if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php'); - exit(); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + if($object->is_erasable()) { + + $result = $object->delete($user, 0, $idwarehouse); + if ($result > 0) { + header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php'); + exit(); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; + } + } }