Fix move the code into mouvementstock class
This commit is contained in:
parent
c62a69ccc8
commit
67392fbac5
@ -251,6 +251,17 @@ class MouvementStock extends CommonObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER) && in_array($type, array(1, 2)))
|
||||||
|
{
|
||||||
|
if (empty($product->stock_warehouse[$entrepot_id]->real) || $product->stock_warehouse[$entrepot_id]->real < abs($qty))
|
||||||
|
{
|
||||||
|
$this->error = $langs->trans('qtyToTranferIsNotEnough');
|
||||||
|
$this->errors[] = $langs->trans('qtyToTranferIsNotEnough');
|
||||||
|
$this->db->rollback();
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Define if we must make the stock change (If product type is a service or if stock is used also for services)
|
// Define if we must make the stock change (If product type is a service or if stock is used also for services)
|
||||||
$movestock=0;
|
$movestock=0;
|
||||||
if ($product->type != Product::TYPE_SERVICE || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock=1;
|
if ($product->type != Product::TYPE_SERVICE || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock=1;
|
||||||
|
|||||||
@ -232,24 +232,6 @@ if ($action == "transfert_stock" && ! $cancel)
|
|||||||
if (isset($object->pmp)) $pricesrc=$object->pmp;
|
if (isset($object->pmp)) $pricesrc=$object->pmp;
|
||||||
$pricedest=$pricesrc;
|
$pricedest=$pricesrc;
|
||||||
|
|
||||||
$do_tranfer = true;
|
|
||||||
if (empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER))
|
|
||||||
{
|
|
||||||
$fk_warehouse_source = GETPOST("id_entrepot");
|
|
||||||
$nb_unit = GETPOST("nbpiece",'int');
|
|
||||||
|
|
||||||
if (empty($object->stock_warehouse[$fk_warehouse_source]->real) || $object->stock_warehouse[$fk_warehouse_source]->real < $nb_unit)
|
|
||||||
{
|
|
||||||
$do_tranfer = false;
|
|
||||||
$result1 = $result2 = -1;
|
|
||||||
$action='';
|
|
||||||
$object->error = $langs->trans('qtyToTranferIsNotEnough');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($do_tranfer)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ($object->hasbatch())
|
if ($object->hasbatch())
|
||||||
{
|
{
|
||||||
$pdluo = new Productbatch($db);
|
$pdluo = new Productbatch($db);
|
||||||
@ -341,7 +323,6 @@ if ($action == "transfert_stock" && ! $cancel)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error && $result1 >= 0 && $result2 >= 0)
|
if (! $error && $result1 >= 0 && $result2 >= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user