Inventory: Do not use batch qty even if present if batch module is disabled.

This commit is contained in:
lainwir3d 2022-04-14 00:37:26 +04:00
parent cb2dd77f49
commit e527ad9a07

View File

@ -306,9 +306,14 @@ class Inventory extends CommonObject
$inventoryline->fk_warehouse = $obj->fk_warehouse; $inventoryline->fk_warehouse = $obj->fk_warehouse;
$inventoryline->fk_product = $obj->fk_product; $inventoryline->fk_product = $obj->fk_product;
$inventoryline->batch = $obj->batch; $inventoryline->batch = $obj->batch;
$inventoryline->qty_stock = ($obj->batch ? $obj->qty : $obj->reel); // If there is batch detail, we take qty for batch, else global qty
$inventoryline->datec = dol_now(); $inventoryline->datec = dol_now();
if ($conf->productbatch->enabled) {
$inventoryline->qty_stock = ($obj->batch ? $obj->qty : $obj->reel); // If there is batch detail, we take qty for batch, else global qty
}else{
$inventoryline->qty_stock = $obj->reel;
}
$resultline = $inventoryline->create($user); $resultline = $inventoryline->create($user);
if ($resultline <= 0) { if ($resultline <= 0) {
$this->error = $inventoryline->error; $this->error = $inventoryline->error;