Merge pull request #8816 from atm-gauthier/6.0_fix_test_before_delete_invoice

FIX : test is_erasable() must be done before call function delete()
This commit is contained in:
Laurent Destailleur 2018-05-25 11:05:20 +02:00 committed by GitHub
commit b25c7e44d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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