Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2018-03-11 00:16:21 +01:00
commit 06689bb79f
2 changed files with 20 additions and 14 deletions

View File

@ -1088,25 +1088,36 @@ class Expedition extends CommonObject
function delete() function delete()
{ {
global $conf, $langs, $user; global $conf, $langs, $user;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if ($conf->productbatch->enabled)
{
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php';
}
$error=0; $error=0;
$this->error=''; $this->error='';
$this->db->begin();
// Add a protection to refuse deleting if shipment has at least one delivery // Add a protection to refuse deleting if shipment has at least one delivery
$this->fetchObjectLinked($this->id, 'shipping', 0, 'delivery'); // Get deliveries linked to this shipment $this->fetchObjectLinked($this->id, 'shipping', 0, 'delivery'); // Get deliveries linked to this shipment
if (count($this->linkedObjectsIds) > 0) if (count($this->linkedObjectsIds) > 0)
{ {
$this->error='ErrorThereIsSomeDeliveries'; $this->error='ErrorThereIsSomeDeliveries';
return -1; $error++;
}
if (! $error)
{
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('SHIPPING_DELETE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
} }
$this->db->begin();
// Stock control // Stock control
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0) if (! $error && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0)
{ {
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
@ -1203,11 +1214,6 @@ class Expedition extends CommonObject
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
// Call trigger
$result=$this->call_trigger('SHIPPING_DELETE',$user);
if ($result < 0) { $error++; }
// End call triggers
if (! empty($this->origin) && $this->origin_id > 0) if (! empty($this->origin) && $this->origin_id > 0)
{ {
$this->fetch_origin(); $this->fetch_origin();