FIX : test is_erasable() must be done before call function delete() too to avoid delete invoice with &action=delete in url

This commit is contained in:
gauthier 2018-05-18 15:20:16 +02:00
parent 7de812d2ed
commit 4c3f9d6d5e

View File

@ -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='';
}
}
}