Skip to content

Commit

Permalink
FIX: Fix create shipping with product who have negative stocks on war…
Browse files Browse the repository at this point in the history
…ehouse but the negative stock transfert is allowed (#26217)
  • Loading branch information
kkhelifa-opendsi authored Mar 8, 2024
1 parent 91b994b commit bcf6d7a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions htdocs/expedition/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@
$nbofsuggested = 0;

foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
if ($stock_warehouse->real > 0) {
if ($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) {
$nbofsuggested++;
}
}
Expand All @@ -1437,7 +1437,7 @@
}

$tmpwarehouseObject->fetch($warehouse_id);
if ($stock_warehouse->real > 0) {
if ($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) {
$stock = + $stock_warehouse->real; // Convert it to number
$deliverableQty = min($quantityToBeDelivered, $stock);
$deliverableQty = max(0, $deliverableQty);
Expand Down Expand Up @@ -1536,7 +1536,7 @@
// Define nb of lines suggested for this order line
$nbofsuggested = 0;
foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) {
if (($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) && (count($stock_warehouse->detail_batch))) {
$nbofsuggested+=count($stock_warehouse->detail_batch);
}
}
Expand All @@ -1549,7 +1549,7 @@
}

$tmpwarehouseObject->fetch($warehouse_id);
if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) {
if (($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) && (count($stock_warehouse->detail_batch))) {
foreach ($stock_warehouse->detail_batch as $dbatch) {
$batchStock = + $dbatch->qty; // To get a numeric
if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
Expand Down Expand Up @@ -1634,6 +1634,9 @@
$disabled = 'disabled="disabled"';
}
print '<input class="qtyl" name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0"'.($disabled ? ' '.$disabled : '').'> ';
if (empty($disabled) && !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) {
print '<input name="ent1' . $indiceAsked . '_' . $subj . '" type="hidden" value="' . $warehouse_selected_id . '">';
}
} else {
print $langs->trans("NA");
}
Expand Down

0 comments on commit bcf6d7a

Please sign in to comment.