diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index b261f51e145..ce552fdd71d 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -63,7 +63,7 @@ if (isModEnabled('project')) { } // Load translation files required by the page -$langs->loadLangs(array("sendings", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal')); +$langs->loadLangs(array("sendings", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal', 'productbatch')); if (isModEnabled('incoterm')) { $langs->load('incoterm'); @@ -1625,7 +1625,7 @@ if ($action == 'create') { if ($result > 0) { print $productlotObject->getNomUrl(1); } else { - print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed'; + print $langs->trans("TableLotIncompleteRunRepairWithParamStandardEqualConfirmed"); } if (empty($conf->global->PRODUCT_DISABLE_SELLBY) && !empty($dbatch->sellby)) { print ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index c51d94b8acd..a84816c9d3c 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -45,3 +45,5 @@ OutOfOrder=Out of order InWorkingOrder=In working order ToReplace=Replace CantMoveNonExistantSerial=Error. You ask a move on a record for a serial that does not exists anymore. May be you take the same serial on same warehouse several times in same shipment or it was used by another shipment. Remove this shipment and prepare another one. +TableLotIncompleteRunRepairWithParamStandardEqualConfirmed=Lot table incomplete run repair with parameter '...repair.php?standard=confirmed' +IlligalQtyForSerialNumbers= Stock correction required because unique serial number. \ No newline at end of file diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 800a9f00b5b..990cd808c7f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -39,6 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; /** @@ -1168,6 +1169,19 @@ class Product extends CommonObject if ($ObjBatch->create($user, 1) < 0) { $error++; $this->errors = $ObjBatch->errors; + } else { + // we also add lot record if not exist + $ObjLot = new Productlot($this->db); + if ($ObjLot->fetch(0, $this->id, $valueforundefinedlot) == 0) { + $ObjLot->fk_product = $this->id; + $ObjLot->entity = $this->entity; + $ObjLot->fk_user_creat = $user->id; + $ObjLot->batch = $valueforundefinedlot; + if ($ObjLot->create($user, true) < 0) { + $error++; + $this->errors = $ObjLot->errors; + } + } } } } diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 63abd714011..649e468cc6d 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -438,7 +438,7 @@ $num = $db->num_rows($resql); $i = 0; -if ($num == 1 && GETPOST('autojumpifoneonly') && ($search_all or $snom or $sref)) { +if ($num == 1 && GETPOST('autojumpifoneonly') && ($search_all || $snom || $sref)) { $objp = $db->fetch_object($resql); header("Location: card.php?id=$objp->rowid"); exit; @@ -830,15 +830,11 @@ while ($i < $imaxinloop) { //if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; if (is_null($objp->stock_physique)) { if (!empty($objp->reel)) { - if ($objp->reel < 0) { print ''; } - print price2num($objp->reel, 'MS'); - if ($objp->reel < 0) { print ''; } + print price2num($objp->reel, 'MS').($objp->stock_physique < 0 ? ' '.img_warning() : ''); } } else { if (!empty($objp->stock_physique)) { - if ($objp->stock_physique < 0) { print ''; } - print price2num($objp->stock_physique, 'MS'); - if ($objp->stock_physique < 0) { print ''; } + print price2num($objp->stock_physique, 'MS').($objp->stock_physique < 0 ? ' '.img_warning() : (($objp->stock_physique > 1 && $objp->tobatch == 2) ? ' '.img_warning($langs->trans('IlligalQtyForSerialNumbers')): '')); } } print ''; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 64331a024d9..ab0b367ca42 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -1166,7 +1166,11 @@ if (!$variants) { print "\n".''; print ''; print ''; - print $product_lot_static->getNomUrl(1); + if ($product_lot_static->id > 0) { + print $product_lot_static->getNomUrl(1); + } else { + print $product_lot_static->getNomUrl(1, 'nolink'); + } print ''; $colspan = 3; if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { @@ -1177,7 +1181,7 @@ if (!$variants) { $colspan--; print ''.dol_print_date($pdluo->eatby, 'day').''; } - print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; + print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : (($pdluo->qty > 1 && $object->status_batch == 2) ? ' '.img_warning($langs->trans('IlligalQtyForSerialNumbers')): '')).''; print ''; print ''; if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) {