Merge pull request #8334 from atm-florian/dev_fixtrigger
fix trigger position into explication class
This commit is contained in:
commit
11abbbcd98
@ -1081,32 +1081,43 @@ 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
|
* @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO
|
||||||
*/
|
*/
|
||||||
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();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user