FIX Delete of draft invoice
This commit is contained in:
parent
85b8c9f219
commit
27d82d0e8e
@ -190,7 +190,7 @@ if (empty($reshook))
|
|||||||
$qualified_for_stock_change = $object->hasProductsOrServices(1);
|
$qualified_for_stock_change = $object->hasProductsOrServices(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($object->is_erasable())
|
if ($object->is_erasable() > 0)
|
||||||
{
|
{
|
||||||
$result = $object->delete($user, 0, $idwarehouse);
|
$result = $object->delete($user, 0, $idwarehouse);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
@ -4812,7 +4812,7 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
$isErasable = $object->is_erasable();
|
$isErasable = $object->is_erasable();
|
||||||
if ($user->rights->facture->supprimer || $isErasable == 1) // isErasable = 1 means draft (draft can always be deleted with no need of permissions)
|
if ($user->rights->facture->supprimer || $isErasable == 1) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions)
|
||||||
{
|
{
|
||||||
//var_dump($isErasable);
|
//var_dump($isErasable);
|
||||||
if ($isErasable == -4) {
|
if ($isErasable == -4) {
|
||||||
|
|||||||
@ -328,12 +328,13 @@ abstract class CommonInvoice extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Return if an invoice can be deleted
|
* Return if an invoice can be deleted
|
||||||
* Rule is:
|
* Rule is:
|
||||||
* If invoice is draft and has a temporary ref -> yes
|
* If invoice is draft and has a temporary ref -> yes (1)
|
||||||
* If hidden option INVOICE_CAN_NEVER_BE_REMOVED is on -> no (0)
|
* If hidden option INVOICE_CAN_NEVER_BE_REMOVED is on -> no (0)
|
||||||
* If invoice is dispatched in bookkeeping -> no (-1)
|
* If invoice is dispatched in bookkeeping -> no (-1)
|
||||||
* If invoice has a definitive ref, is not last and INVOICE_CAN_ALWAYS_BE_REMOVED off -> no (-2)
|
* If invoice has a definitive ref, is not last and INVOICE_CAN_ALWAYS_BE_REMOVED off -> no (-2)
|
||||||
* If invoice not last in a cycle -> no (-3)
|
* If invoice not last in a cycle -> no (-3)
|
||||||
* If there is payment -> no (-4)
|
* If there is payment -> no (-4)
|
||||||
|
* Otherwise -> yes (2)
|
||||||
*
|
*
|
||||||
* @return int <=0 if no, >0 if yes
|
* @return int <=0 if no, >0 if yes
|
||||||
*/
|
*/
|
||||||
@ -381,7 +382,7 @@ abstract class CommonInvoice extends CommonObject
|
|||||||
// Test if there is at least one payment. If yes, refuse to delete.
|
// Test if there is at least one payment. If yes, refuse to delete.
|
||||||
if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4;
|
if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4;
|
||||||
|
|
||||||
return 1;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -3117,9 +3117,9 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if ($action != 'confirm_edit' && $user->rights->fournisseur->facture->supprimer)
|
|
||||||
{
|
|
||||||
$isErasable=$object->is_erasable();
|
$isErasable=$object->is_erasable();
|
||||||
|
if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || $isErasable == 1)) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions)
|
||||||
|
{
|
||||||
//var_dump($isErasable);
|
//var_dump($isErasable);
|
||||||
if ($isErasable == -4) {
|
if ($isErasable == -4) {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("DisabledBecausePayments") . '">' . $langs->trans('Delete') . '</a></div>';
|
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("DisabledBecausePayments") . '">' . $langs->trans('Delete') . '</a></div>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user