diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 6744af04022..66596252b77 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -421,17 +421,18 @@ class MouvementStock extends CommonObject if (isModEnabled('productbatch') && $product->hasbatch() && !$skip_batch) { $foundforbatch = 0; $qtyisnotenough = 0; + if (isset($product->stock_warehouse[$entrepot_id])) { + foreach ($product->stock_warehouse[$entrepot_id]->detail_batch as $batchcursor => $prodbatch) { + if ((string) $batch != (string) $batchcursor) { // Lot '59' must be different than lot '59c' + continue; + } - foreach ($product->stock_warehouse[$entrepot_id]->detail_batch as $batchcursor => $prodbatch) { - if ((string) $batch != (string) $batchcursor) { // Lot '59' must be different than lot '59c' - continue; + $foundforbatch = 1; + if ($prodbatch->qty < abs($qty)) { + $qtyisnotenough = $prodbatch->qty; + } + break; } - - $foundforbatch = 1; - if ($prodbatch->qty < abs($qty)) { - $qtyisnotenough = $prodbatch->qty; - } - break; } if (!$foundforbatch || $qtyisnotenough) { $langs->load("stocks"); @@ -445,7 +446,7 @@ class MouvementStock extends CommonObject return -8; } } else { - if (empty($product->stock_warehouse[$entrepot_id]->real) || $product->stock_warehouse[$entrepot_id]->real < abs($qty)) { + if (isset($product->stock_warehouse[$entrepot_id]) && (empty($product->stock_warehouse[$entrepot_id]->real) || $product->stock_warehouse[$entrepot_id]->real < abs($qty))) { $langs->load("stocks"); $this->error = $langs->trans('qtyToTranferIsNotEnough').' : '.$product->ref; $this->errors[] = $langs->trans('qtyToTranferIsNotEnough').' : '.$product->ref; diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php index 96b228fba9e..1d0f6dd607e 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php @@ -189,10 +189,15 @@ if (empty($reshook)) { } else { if (!empty($batch)) { $error++; - setEventMessages($langs->transnoentities('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors'); + setEventMessages($langs->transnoentities('StockTransferNoBatchForProduct', $prod->getNomUrl()), null, 'errors'); } } + if ($prod->status_batch==2 && abs($qty)>1) { + $error++; + setEventMessages($langs->transnoentities('TooManyQtyForSerialNumber', $prod->ref), null, 'errors'); + } + if (empty($error)) { $line = new StockTransferLine($db); $records = $line->fetchAll('', '', 0, 0, '(fk_stocktransfer:=:'.((int) $id).') AND (fk_product:=:'.((int) $fk_product).') AND (fk_warehouse_source:=:'.((int) $fk_warehouse_source).') AND (fk_warehouse_destination:=:'.((int) $fk_warehouse_destination).') AND ('.(empty($batch) ? "(batch:=:'') OR (batch:IS:NULL)" : "batch:=:'".$db->escape($batch)."'").')'); @@ -251,6 +256,12 @@ if (empty($reshook)) { } } + if ($prod->status_batch==2 && abs($qty)>1) { + $error++; + setEventMessages($langs->transnoentities('TooManyQtyForSerialNumber', $prod->ref), null, 'errors'); + $action = 'editline'; + } + if (empty($error)) { $line = new StockTransferLine($db); $line->fetch($lineid); @@ -446,6 +457,10 @@ if ($action == 'create') { include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; if (isModEnabled('incoterm')) { + $soc = new Societe($db); + if (!empty($object->fk_soc)) { + $soc->fetch($object->fk_soc); + } print ''; print ''; print ''; @@ -605,7 +620,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref = '
'; // Thirdparty $morehtmlref .= empty($object->thirdparty) ? '' : $object->thirdparty->getNomUrl(1, 'customer'); - if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { + if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && !empty($object->thirdparty) && $object->thirdparty->id > 0) { $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; } // Project @@ -707,6 +722,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea */ if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + $fk_element = $object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } @@ -804,7 +820,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; if ($action === 'editline' && $line->id == $lineid) { - $form->select_produits($line->fk_product, 'fk_product', $filtertype, $limit, 0, -1, 2, '', 0, array(), 0, 0, 0, 'minwidth200imp maxwidth300', 1); + $form->select_produits($line->fk_product, 'fk_product', '', 0, 0, -1, 2, '', 0, array(), 0, 0, 0, 'minwidth200imp maxwidth300', 1); } else { print $productstatic->getNomUrl(1).' - '.$productstatic->label; } @@ -827,14 +843,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($action === 'editline' && $line->id == $lineid) { - print $formproduct->selectWarehouses($line->fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseSource); + print $formproduct->selectWarehouses($line->fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); } else { print $warehousestatics->getNomUrl(1); } print ''; print ''; if ($action === 'editline' && $line->id == $lineid) { - print $formproduct->selectWarehouses($line->fk_warehouse_destination, 'fk_warehouse_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseDestination); + print $formproduct->selectWarehouses($line->fk_warehouse_destination, 'fk_warehouse_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); } else { print $warehousestatict->getNomUrl(1); } @@ -879,7 +895,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($num > 1 && $conf->browser->layout != 'phone' && empty($disablemove)) { print ''; - $coldisplay++; if ($i > 0) { ?> id; ?>"> @@ -893,7 +908,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } else { print 'browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>'; - $coldisplay++; } } @@ -1098,7 +1112,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'stocktransfer', 0, 1, '', $MAXEVENT, '', $morehtmlright); + $somethingshown = $formactions->showactions($object, 'stocktransfer', 0, 1, '', $MAXEVENT, ''); print '
'; }