FIX: update product with stock to lot or serial type. (#23002)

* git init

* Fixing style errors.

* Add split of serial defaults

* Fix remaining part

* Fix on  remaining decimal part

* Revert "Fix on  remaining decimal part"

This reverts commit b91f884ddc798777c6539933bf235c81f739bec8.

* Revert "Fix remaining part"

This reverts commit 35a6631b29a01544a48a4c80f8f7a65455dab0bf.

* Revert "Add split of serial defaults"

This reverts commit 37009afcbc91a6cef1743e29ee5a201d01fb410c.

* Remove split for serial numbers and replace by error message.

* Fix stickler CI

* Fix missing product id for lot number fetch

* Allow update for data consistency, but show warning in stock card and stocks by lot/serial list

---------

Co-authored-by: Francis Appels <francis@vps399724.ovh.net.novalocal>
Co-authored-by: stickler-ci <support@stickler-ci.com>
This commit is contained in:
Francis Appels 2023-10-31 11:47:38 +01:00 committed by GitHub
parent 48ddc2408a
commit ee269b4608
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 11 deletions

View file

@ -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");

View file

@ -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.

View file

@ -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;
}
}
}
}
}

View file

@ -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 '<span class="warning">'; }
print price2num($objp->reel, 'MS');
if ($objp->reel < 0) { print '</span>'; }
print price2num($objp->reel, 'MS').($objp->stock_physique < 0 ? ' '.img_warning() : '');
}
} else {
if (!empty($objp->stock_physique)) {
if ($objp->stock_physique < 0) { print '<span class="warning">'; }
print price2num($objp->stock_physique, 'MS');
if ($objp->stock_physique < 0) { print '</span>'; }
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 '</td>';

View file

@ -1166,7 +1166,11 @@ if (!$variants) {
print "\n".'<tr style="display:'.(empty($conf->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT) ? 'none' : 'visible').';" class="batch_warehouse'.$entrepotstatic->id.'"><td class="left">';
print '</td>';
print '<td class="right nowraponall">';
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 '</td>';
$colspan = 3;
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
@ -1177,7 +1181,7 @@ if (!$variants) {
$colspan--;
print '<td class="center">'.dol_print_date($pdluo->eatby, 'day').'</td>';
}
print '<td class="right" colspan="'.$colspan.'">'.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').'</td>';
print '<td class="right" colspan="'.$colspan.'">'.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : (($pdluo->qty > 1 && $object->status_batch == 2) ? ' '.img_warning($langs->trans('IlligalQtyForSerialNumbers')): '')).'</td>';
print '<td colspan="4"></td>';
print '<td class="center tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans("TransferStock")).'">';
if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) {