FIX When deleting last shipment, status "shipment in progress" of order

must move back to status "validated".
This commit is contained in:
Laurent Destailleur 2016-04-01 16:59:08 +02:00
parent e40b678d7b
commit d14f3d7e2b
2 changed files with 22 additions and 2 deletions

View File

@ -166,9 +166,13 @@ class Commande extends CommonOrder
*/
const STATUS_VALIDATED = 1;
/**
* Accepted/On process not managed for customer orders
* Accepted (supplier orders)
*/
const STATUS_ACCEPTED = 2;
/**
* Shipment on process (customer orders)
*/
const STATUS_SHIPMENTONPROCESS = 2;
/**
* Closed (Sent/Received, billed or not)
*/
@ -1833,7 +1837,7 @@ class Commande extends CommonOrder
}
/**
* Load array this->expeditions of nb of products sent by line in order
* Load array this->expeditions of lines of shipments with nb of products sent for each order line
*
* @param int $filtre_statut Filter on status
* @return int <0 if KO, Nb of lines found if OK

View File

@ -1204,6 +1204,22 @@ class Expedition extends CommonObject
if ($result < 0) { $error++; }
// End call triggers
if (! empty($this->origin) && $this->origin_id > 0)
{
$this->fetch_origin();
$origin=$this->origin;
if ($this->$origin->statut == Commande::STATUS_SHIPMENTONPROCESS) // If order source of shipment is "shipment in progress"
{
// Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress"
$this->$origin->loadExpeditions();
//var_dump($this->$origin->expeditions);exit;
if (count($this->$origin->expeditions) <= 0)
{
$this->$origin->setStatut(Commande::STATUS_VALIDATED);
}
}
}
if (! $error)
{
$this->db->commit();