Fix: Change status of order to cancel
This commit is contained in:
parent
9f65a33f04
commit
5ff9286a1f
@ -461,6 +461,8 @@ class Commande extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
|
||||||
if ($user->rights->commande->valider)
|
if ($user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -470,6 +472,7 @@ class Commande extends CommonObject
|
|||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
$sql.= " AND fk_statut = 1";
|
$sql.= " AND fk_statut = 1";
|
||||||
|
|
||||||
|
dol_syslog("Commande::cancel sql=".$sql, LOG_DEBUG);
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
// If stock is decremented on validate order, we must reincrement it
|
// If stock is decremented on validate order, we must reincrement it
|
||||||
@ -477,13 +480,18 @@ class Commande extends CommonObject
|
|||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
|
||||||
|
|
||||||
$mouvP = new MouvementStock($this->db);
|
if ($this->lignes[$i]->fk_product > 0 && $this->lignes[$i]->product_type == 0)
|
||||||
// We increment stock of product (and sub-products)
|
|
||||||
$entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot
|
|
||||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice);
|
|
||||||
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
{
|
||||||
|
$mouvP = new MouvementStock($this->db);
|
||||||
|
// We increment stock of product (and sub-products)
|
||||||
|
$entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot
|
||||||
|
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice);
|
||||||
|
if ($result < 0) { $error++; }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->statut=-1;
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user