Merge pull request #11433 from atm-florianm/FIX_increase_stock_on_shipment_delete_when_STOCK_CALCULATE_ON_SHIPMENT_CLOSE_is_set
FIX: stock increase on shipment deletion if STOCK_CALCULATE_ON_SHIPMENT_CLOSE is set
This commit is contained in:
commit
917799914e
@ -468,7 +468,8 @@ if (empty($reshook))
|
|||||||
|
|
||||||
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer)
|
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer)
|
||||||
{
|
{
|
||||||
$result = $object->delete();
|
$also_update_stock = GETPOST('alsoUpdateStock', 'alpha') ?: 0;
|
||||||
|
$result = $object->delete($also_update_stock);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
header("Location: ".DOL_URL_ROOT.'/expedition/index.php');
|
header("Location: ".DOL_URL_ROOT.'/expedition/index.php');
|
||||||
@ -1648,7 +1649,26 @@ else if ($id || $ref)
|
|||||||
// Confirm deleteion
|
// Confirm deleteion
|
||||||
if ($action == 'delete')
|
if ($action == 'delete')
|
||||||
{
|
{
|
||||||
$formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('DeleteSending'),$langs->trans("ConfirmDeleteSending",$object->ref),'confirm_delete','',0,1);
|
$formquestion = array();
|
||||||
|
if ($object->statut == Expedition::STATUS_CLOSED && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
|
||||||
|
$formquestion = array(
|
||||||
|
array(
|
||||||
|
'label' => $langs->trans('ShipmentIncrementStockOnDelete'),
|
||||||
|
'name' => 'alsoUpdateStock',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'value' => 0
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$formconfirm=$form->formconfirm(
|
||||||
|
$_SERVER['PHP_SELF'].'?id='.$object->id,
|
||||||
|
$langs->trans('DeleteSending'),
|
||||||
|
$langs->trans("ConfirmDeleteSending",$object->ref),
|
||||||
|
'confirm_delete',
|
||||||
|
$formquestion,
|
||||||
|
0,
|
||||||
|
1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirmation validation
|
// Confirmation validation
|
||||||
|
|||||||
@ -1073,13 +1073,15 @@ class Expedition extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete shipment.
|
* Delete shipment.
|
||||||
* Warning, do not delete a shipment if a delivery is linked to (with table llx_element_element)
|
* Warning, do not delete a shipment if a delivery is linked to (with table llx_element_element)
|
||||||
*
|
*
|
||||||
* @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO
|
* @param bool $also_update_stock true if the stock should be increased back (false by default)
|
||||||
*/
|
* @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO
|
||||||
function delete()
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function delete($also_update_stock = false)
|
||||||
{
|
{
|
||||||
global $conf, $langs, $user;
|
global $conf, $langs, $user;
|
||||||
|
|
||||||
@ -1111,7 +1113,9 @@ class Expedition extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stock control
|
// Stock control
|
||||||
if (! $error && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT)
|
if (! $error && $conf->stock->enabled &&
|
||||||
|
(($conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) ||
|
||||||
|
($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE && $this->statut == self::STATUS_CLOSED && $also_update_stock)))
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
||||||
|
|
||||||
|
|||||||
@ -60,6 +60,8 @@ NoProductToShipFoundIntoStock=Aucun produit à expédier n'a été trouver dans
|
|||||||
WeightVolShort=Poids/vol.
|
WeightVolShort=Poids/vol.
|
||||||
ValidateOrderFirstBeforeShipment=Vous devez d'abord valider la commande pour pouvoir créer une expédition.
|
ValidateOrderFirstBeforeShipment=Vous devez d'abord valider la commande pour pouvoir créer une expédition.
|
||||||
|
|
||||||
|
ShipmentIncrementStockOnDelete=Remettre en stock les éléments de cette expédition
|
||||||
|
|
||||||
# Sending methods
|
# Sending methods
|
||||||
# ModelDocument
|
# ModelDocument
|
||||||
DocumentModelTyphon=Modèle de bon de réception/livraison complet (logo…)
|
DocumentModelTyphon=Modèle de bon de réception/livraison complet (logo…)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user