Merge pull request #10505 from ATM-Marc/FIX_7.0_expedition_status

FIX: expedition: reset status on rollback
This commit is contained in:
Laurent Destailleur 2019-02-08 09:46:14 +01:00 committed by GitHub
commit 76b021d061
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -538,7 +538,7 @@ class Expedition extends CommonObject
$this->db->free($result);
if ($this->statut == 0) $this->brouillon = 1;
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Tracking url
$this->GetUrlTrackingStatus($obj->tracking_number);
@ -783,7 +783,7 @@ class Expedition extends CommonObject
if (! $error)
{
$this->ref = $numref;
$this->statut = 1;
$this->statut = self::STATUS_VALIDATED;
}
if (! $error)
@ -816,7 +816,7 @@ class Expedition extends CommonObject
if ($conf->livraison_bon->enabled)
{
if ($this->statut == 1 || $this->statut == 2)
if ($this->statut == self::STATUS_VALIDATED || $this->statut == self::STATUS_CLOSED)
{
// Expedition validee
include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php';
@ -1111,7 +1111,7 @@ class Expedition extends CommonObject
$this->db->begin();
// Stock control
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0)
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT)
{
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
@ -1663,7 +1663,7 @@ class Expedition extends CommonObject
$this->id=0;
$this->ref = 'SPECIMEN';
$this->specimen=1;
$this->statut = 1;
$this->statut = self::STATUS_VALIDATED;
$this->livraison_id = 0;
$this->date = $now;
$this->date_creation = $now;
@ -2037,6 +2037,7 @@ class Expedition extends CommonObject
}
else
{
$this->statut = self::STATUS_VALIDATED;
$this->db->rollback();
return -1;
}
@ -2060,7 +2061,7 @@ class Expedition extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
$this->statut=2;
$this->statut=self::STATUS_CLOSED;
$this->billed=1;
// Call trigger
@ -2080,6 +2081,8 @@ class Expedition extends CommonObject
}
else
{
$this->statut=self::STATUS_VALIDATED;
$this->billed=0;
$this->db->rollback();
return -1;
}
@ -2104,13 +2107,15 @@ class Expedition extends CommonObject
$this->db->begin();
$oldbilled=$this->billed;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
$resql=$this->db->query($sql);
if ($resql)
{
$this->statut=1;
$this->statut=self::STATUS_VALIDATED;
$this->billed=0;
// If stock increment is done on closing
@ -2208,6 +2213,8 @@ class Expedition extends CommonObject
}
else
{
$this->statut=self::STATUS_CLOSED;
$this->billed=$oldbilled;
$this->db->rollback();
return -1;
}