Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
06689bb79f
@ -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();
|
||||||
@ -2440,7 +2446,7 @@ class ExpeditionLigne extends CommonObjectLine
|
|||||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1*$error;
|
return -1*$error;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -200,7 +200,7 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Test for non key files only
|
// Test for non key files only
|
||||||
$result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY ') == 0);
|
$result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY') == 0);
|
||||||
print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n";
|
print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n";
|
||||||
$this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.');
|
$this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.');
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user