Modification de l'enregistrement des mouvements de stock
Désormais l'enregistrement a lieu lors de la validation de l'expedition
This commit is contained in:
parent
7877f46ce2
commit
3039597582
@ -136,7 +136,6 @@ class Expedition
|
|||||||
Function create_line($transaction, $commande_ligne_id, $qty)
|
Function create_line($transaction, $commande_ligne_id, $qty)
|
||||||
{
|
{
|
||||||
$error = 0;
|
$error = 0;
|
||||||
$mouvS = new MouvementStock($this->db);
|
|
||||||
|
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
$j = 0;
|
$j = 0;
|
||||||
@ -149,11 +148,6 @@ class Expedition
|
|||||||
$j++;
|
$j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $mouvS->livraison($this->user, $idprod, $this->entrepot_id, $qty, 0) )
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_commande_ligne, qty)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_commande_ligne, qty)";
|
||||||
$sql .= " VALUES ($this->id,".$commande_ligne_id.",".$qty.")";
|
$sql .= " VALUES ($this->id,".$commande_ligne_id.",".$qty.")";
|
||||||
|
|
||||||
@ -213,6 +207,8 @@ class Expedition
|
|||||||
*/
|
*/
|
||||||
Function valid($user)
|
Function valid($user)
|
||||||
{
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
|
||||||
|
|
||||||
$result = 0;
|
$result = 0;
|
||||||
if ($user->rights->expedition->valider)
|
if ($user->rights->expedition->valider)
|
||||||
{
|
{
|
||||||
@ -223,6 +219,29 @@ class Expedition
|
|||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$result = 1;
|
$result = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enregistrement d'un mouvement de stock
|
||||||
|
* pour chaque ligne produit de l'expedition
|
||||||
|
*/
|
||||||
|
|
||||||
|
$sql = "SELECT cd.fk_product, ed.qty ";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed";
|
||||||
|
$sql .= " WHERE ed.fk_expedition = $this->id AND cd.rowid = ed.fk_commande_ligne ";
|
||||||
|
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows();
|
||||||
|
$i=0;
|
||||||
|
while($i < $num)
|
||||||
|
{
|
||||||
|
$mouvS = new MouvementStock($this->db);
|
||||||
|
$obj = $this->db->fetch_object($i);
|
||||||
|
$mouvS->livraison($user, $obj->fk_product, $this->entrepot_id, $obj->qty, 0);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user