forked from Wavyzz/dolibarr
NEW shipment kits with dispatcher v2 (#33750)
* NEW shipment kits with dispatcher v2 * Show stock of virtual product on select warehouse when dispatching a shipment --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
committed by
GitHub
parent
de763b4b43
commit
c85cc3061b
@@ -1646,13 +1646,38 @@ class Commande extends CommonOrder
|
||||
$result = $product->fetch($fk_product);
|
||||
$product_type = $product->type;
|
||||
|
||||
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_ORDER') && $product_type == 0 && $product->stock_reel < $qty) {
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
|
||||
$this->errors[] = $this->error;
|
||||
dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return self::STOCK_NOT_ENOUGH_FOR_ORDER;
|
||||
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_ORDER') && $product_type == 0) {
|
||||
// get real stock
|
||||
$productChildrenNb = 0;
|
||||
if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
|
||||
$productChildrenNb = $product->hasFatherOrChild(1);
|
||||
}
|
||||
if ($productChildrenNb > 0) {
|
||||
// compute real stock from each subcomponent
|
||||
$product_stock = null;
|
||||
$product->loadStockForVirtualProduct('warehouseopen', $qty);
|
||||
foreach ($product->stock_warehouse as $componentStockWarehouse) {
|
||||
if ($product_stock === null) {
|
||||
$product_stock = $componentStockWarehouse->real;
|
||||
} else {
|
||||
$product_stock = min($product_stock, $componentStockWarehouse->real);
|
||||
}
|
||||
}
|
||||
if ($product_stock === null) {
|
||||
$product_stock = 0;
|
||||
}
|
||||
} else {
|
||||
$product_stock = $product->stock_reel;
|
||||
}
|
||||
|
||||
if ($product_stock < $qty) {
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
|
||||
$this->errors[] = $this->error;
|
||||
dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return self::STOCK_NOT_ENOUGH_FOR_ORDER;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
@@ -3187,15 +3212,40 @@ class Commande extends CommonOrder
|
||||
$result = $product->fetch($line->fk_product);
|
||||
$product_type = $product->type;
|
||||
|
||||
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_ORDER') && $product_type == 0 && $product->stock_reel < $qty) {
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
|
||||
$this->errors[] = $this->error;
|
||||
if (getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_ORDER') && $product_type == 0) {
|
||||
// get real stock
|
||||
$productChildrenNb = 0;
|
||||
if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
|
||||
$productChildrenNb = $product->hasFatherOrChild(1);
|
||||
}
|
||||
if ($productChildrenNb > 0) {
|
||||
// compute real stock from each subcomponent
|
||||
$product_stock = null;
|
||||
$product->loadStockForVirtualProduct('warehouseopen', $qty);
|
||||
foreach ($product->stock_warehouse as $componentStockWarehouse) {
|
||||
if ($product_stock === null) {
|
||||
$product_stock = $componentStockWarehouse->real;
|
||||
} else {
|
||||
$product_stock = min($product_stock, $componentStockWarehouse->real);
|
||||
}
|
||||
}
|
||||
if ($product_stock === null) {
|
||||
$product_stock = 0;
|
||||
}
|
||||
} else {
|
||||
$product_stock = $product->stock_reel;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
|
||||
if ($product_stock < $qty) {
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
|
||||
$this->errors[] = $this->error;
|
||||
|
||||
$this->db->rollback();
|
||||
return self::STOCK_NOT_ENOUGH_FOR_ORDER;
|
||||
dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
|
||||
|
||||
$this->db->rollback();
|
||||
return self::STOCK_NOT_ENOUGH_FOR_ORDER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user