diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index c6fa8c698819e..6541faf65616b 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -1413,9 +1413,41 @@
//var_dump($dbatch);
$batchStock = + $dbatch->qty; // To get a numeric
$deliverableQty = min($quantityToBeDelivered, $batchStock);
+
+ // Now we will check if we have to reduce the deliverableQty by taking into account the qty already suggested in previous line
+ if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
+ $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
+ } else {
+ if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
+ $alreadyQtyBatchSetted[$line->fk_product] = array();
+ }
+
+ if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
+ $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
+ }
+
+ $deliverableQty = min($quantityToBeDelivered, $batchStock);
+ }
+
+ if ($deliverableQty < 0) $deliverableQty = 0;
+
+ $inputName = 'qtyl'.$indiceAsked.'_'.$subj;
+ if (GETPOSTISSET($inputName)) {
+ $deliverableQty = GETPOST($inputName, 'int');
+ }
+
+ $tooltipClass = $tooltipTitle = '';
+ if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
+ $tooltipClass = ' classfortooltip';
+ $tooltipTitle = $langs->trans('StockQuantitiesAlreadyAllocatedOnPreviousLines').' : '.$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
+ } else {
+ $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0 ;
+ }
+ $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
+
print '
';
print ' | ';
- print '';
+ print '';
print ' | ';
print '';
@@ -1514,9 +1546,10 @@
$deliverableQty = 0;
}
- $tooltip = '';
+ $tooltipClass = $tooltipTitle = '';
if (!empty($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
- $tooltip = ' class="classfortooltip" title="'.$langs->trans('StockQuantitiesAlreadyAllocatedOnPreviousLines').' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)].'" ';
+ $tooltipClass = ' classfortooltip';
+ $tooltipTitle = $langs->trans('StockQuantitiesAlreadyAllocatedOnPreviousLines').' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
} else {
$alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = 0;
}
@@ -1528,7 +1561,7 @@
$deliverableQty = GETPOSTINT($inputName);
}
- print '';
+ print '';
print '';
} else {
if (getDolGlobalString('SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) {
diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php
index cf72a2ac5b9a8..31404030fdb81 100644
--- a/htdocs/mrp/class/mo.class.php
+++ b/htdocs/mrp/class/mo.class.php
@@ -2046,8 +2046,8 @@ class MoLine extends CommonObjectLine
'fk_product' => array('type' => 'integer', 'label' => 'Product', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 25),
'fk_warehouse' => array('type' => 'integer', 'label' => 'Warehouse', 'enabled' => 1, 'visible' => -1, 'position' => 30),
'qty' => array('type' => 'real', 'label' => 'Qty', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 35),
- 'qty_frozen' => array('type' => 'smallint', 'label' => 'QuantityFrozen', 'enabled' => 1, 'visible' => 1, 'default' => '0', 'position' => 105, 'css' => 'maxwidth50imp', 'help' => 'QuantityConsumedInvariable'),
- 'disable_stock_change' => array('type' => 'smallint', 'label' => 'DisableStockChange', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'default' => '0', 'position' => 108, 'css' => 'maxwidth50imp', 'help' => 'DisableStockChangeHelp'),
+ 'qty_frozen' => array('type' => 'smallint', 'label' => 'QuantityFrozen', 'enabled' => 1, 'visible' => 1, 'default' => '0', 'notnull' => 1, 'position' => 105, 'css' => 'maxwidth50imp', 'help' => 'QuantityConsumedInvariable'),
+ 'disable_stock_change' => array('type' => 'smallint', 'label' => 'DisableStockChange', 'enabled' => 1, 'visible' => 1, 'default' => '0', 'notnull' => 1, 'position' => 108, 'css' => 'maxwidth50imp', 'help' => 'DisableStockChangeHelp'),
'batch' => array('type' => 'varchar(30)', 'label' => 'Batch', 'enabled' => 1, 'visible' => -1, 'position' => 140),
'role' => array('type' => 'varchar(10)', 'label' => 'Role', 'enabled' => 1, 'visible' => -1, 'position' => 145),
'fk_mrp_production' => array('type' => 'integer', 'label' => 'Fk mrp production', 'enabled' => 1, 'visible' => -1, 'position' => 150),