-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEW : allow stock management by product #30230
Changes from 26 commits
387d272
7c03476
53645ff
29904fd
8dd43c8
1566d18
7b3262c
2362323
4944282
1a6ad59
ab52991
63cab3b
cb731c1
ec71157
b1e6de6
014b504
7ed6877
c34c7e9
ede7e03
dba9f7b
810d4a3
a308088
dd45b38
57e455d
28517af
a47396f
a055302
c3f6546
62c1f29
d38c728
acc97e9
9ce2ab2
2ac2deb
260f73a
78e6d43
cc60e9f
91d7bca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,6 +271,7 @@ | |
$subtotalqty = 0; | ||
|
||
$j = 0; | ||
|
||
$batch = "batchl".$i."_0"; | ||
$stockLocation = "ent1".$i."_0"; | ||
$qty = "qtyl".$i; | ||
|
@@ -343,6 +344,30 @@ | |
$qty = "qtyl".$i.'_'.$j; | ||
} | ||
} else { | ||
$p = new Product($db); | ||
$res = $p->fetch($objectsrc->lines[$i]->fk_product); | ||
if ($res > 0) { | ||
if (GETPOST('entrepot_id', 'int') == -1) { | ||
$qty .= '_'.$j; | ||
} | ||
|
||
if ($p->stockable_product == Product::DISABLED_STOCK) { | ||
$w = new Entrepot($db); | ||
$Tw = $w->list_array(); | ||
if (count($Tw) > 0) { | ||
$w_Id = array_keys($Tw); | ||
$stockLine[$i][$j]['qty'] = GETPOST($qty, 'int'); | ||
|
||
// lorsque que l'on a le stock désactivé sur un produit/service | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. French comment not allowed |
||
// on force l'entrepot pour passer le test d'ajout de ligne dans expedition.class.php | ||
// | ||
$stockLine[$i][$j]['warehouse_id'] = $w_Id[0]; | ||
$stockLine[$i][$j]['ix_l'] = GETPOST($idl, 'int'); | ||
} else { | ||
setEventMessage($langs->trans('NoWarehouseInBase')); | ||
} | ||
} | ||
} | ||
//shipment line for product with no batch management and no multiple stock location | ||
if (GETPOSTINT($qty) > 0) { | ||
$totalqty += price2num(GETPOST($qty, 'alpha'), 'MS'); | ||
|
@@ -1235,7 +1260,7 @@ | |
$text = $product_static->getNomUrl(1); | ||
$text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); | ||
$description = ($showdescinproductdesc ? '' : dol_htmlentitiesbr($line->desc)); | ||
|
||
$description .= empty($product->stockable_product) ? $langs->trans('StockDisabled') : $langs->trans('StockEnabled'); | ||
print $form->textwithtooltip($text, $description, 3, '', '', $i); | ||
|
||
// Show range | ||
|
@@ -1345,8 +1370,11 @@ | |
if (!getDolGlobalInt('STOCK_ALLOW_NEGATIVE_TRANSFER')) { | ||
$stockMin = 0; | ||
} | ||
print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1, 0, array(), 'minwidth200', '', 1, $stockMin, 'stock DESC, e.ref'); | ||
|
||
if ($product->stockable_product == Product::ENABLED_STOCK) { | ||
print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1, 0, array(), 'minwidth200', '', 1, $stockMin, 'stock DESC, e.ref'); | ||
} else { | ||
print img_warning().' '.$langs->trans('StockDisabled'); | ||
} | ||
if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) { | ||
//print $stock.' '.$quantityToBeDelivered; | ||
if ($stock < $quantityToBeDelivered) { | ||
|
@@ -1577,10 +1605,13 @@ | |
if (isModEnabled('stock')) { | ||
print '<td class="left">'; | ||
if ($line->product_type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { | ||
print $tmpwarehouseObject->getNomUrl(0).' '; | ||
|
||
print '<!-- Show details of stock -->'; | ||
print '('.$stock.')'; | ||
if ($product->stockable_product == Product::ENABLED_STOCK) { | ||
print $tmpwarehouseObject->getNomUrl(0).' '; | ||
print '<!-- Show details of stock -->'; | ||
print '('.$stock.')'; | ||
} else { | ||
print img_warning().' '.$langs->trans('StockDisabled'); | ||
} | ||
} else { | ||
print '<span class="opacitymedium">('.$langs->trans("Service").')</span>'; | ||
} | ||
|
@@ -1740,6 +1771,10 @@ | |
if ($warehouse_selected_id <= 0) { // We did not force a given warehouse, so we won't have no warehouse to change qty. | ||
$disabled = 'disabled="disabled"'; | ||
} | ||
// finally we overwrite the input with the product status stockable_product if it's disabled | ||
if ($product->stockable_product == Product::DISABLED_STOCK) { | ||
$disabled = ''; | ||
} | ||
print '<input class="qtyl right" name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0"'.($disabled ? ' '.$disabled : '').'> '; | ||
if (empty($disabled) && getDolGlobalString('STOCK_ALLOW_NEGATIVE_TRANSFER')) { | ||
print '<input name="ent1' . $indiceAsked . '_' . $subj . '" type="hidden" value="' . $warehouse_selected_id . '">'; | ||
|
@@ -1757,7 +1792,11 @@ | |
print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->label); | ||
} else { | ||
if ($line->fk_product) { | ||
print img_warning().' '.$langs->trans("StockTooLow"); | ||
if ($product->stockable_product == Product::ENABLED_STOCK) { | ||
print img_warning().' '.$langs->trans('StockTooLow'); | ||
} else { | ||
print img_warning().' '.$langs->trans('StockDisabled'); | ||
} | ||
} else { | ||
print ''; | ||
} | ||
|
@@ -2365,6 +2404,7 @@ | |
$product_static->surface_units = $lines[$i]->surface_units; | ||
$product_static->volume = $lines[$i]->volume; | ||
$product_static->volume_units = $lines[$i]->volume_units; | ||
$product_static->stockable_product = $lines[$i]->stockable_product; | ||
|
||
$text = $product_static->getNomUrl(1); | ||
$text .= ' - '.$label; | ||
|
@@ -2535,7 +2575,7 @@ | |
print '<td class="linecolwarehousesource tdoverflowmax200">'; | ||
if ($lines[$i]->product_type == Product::TYPE_SERVICE && getDolGlobalString('SHIPMENT_SUPPORTS_SERVICES')) { | ||
print '<span class="opacitymedium">('.$langs->trans("Service").')</span>'; | ||
} elseif ($lines[$i]->entrepot_id > 0) { | ||
} elseif ($lines[$i]->entrepot_id > 0 && $lines[$i]->stockable_product == Product::ENABLED_STOCK) { | ||
$entrepot = new Entrepot($db); | ||
$entrepot->fetch($lines[$i]->entrepot_id); | ||
print $entrepot->getNomUrl(1); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -971,7 +971,7 @@ public function addline($entrepot_id, $id, $qty, $array_options = []) | |
$isavirtualproduct = ($product->hasFatherOrChild(1) > 0); | ||
// The product is qualified for a check of quantity (must be enough in stock to be added into shipment). | ||
if (!$isavirtualproduct || !getDolGlobalString('PRODUIT_SOUSPRODUITS') || ($isavirtualproduct && !getDolGlobalString('STOCK_EXCLUDE_VIRTUAL_PRODUCTS'))) { // If STOCK_EXCLUDE_VIRTUAL_PRODUCTS is set, we do not manage stock for kits/virtual products. | ||
if ($product_stock < $qty) { | ||
if ($product_stock < $qty && $product->stockable_product == Product::ENABLED_STOCK) { | ||
$langs->load("errors"); | ||
$this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $product->ref); | ||
$this->errorhidden = 'ErrorStockIsNotEnoughToAddProductOnShipment'; | ||
|
@@ -1627,7 +1627,9 @@ public function fetch_lines() | |
$sql .= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc, cd.rang, cd.date_start, cd.date_end"; | ||
$sql .= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_element, ed.fk_elementdet, ed.element_type, ed.fk_entrepot"; | ||
$sql .= ", p.ref as product_ref, p.label as product_label, p.fk_product_type, p.barcode as product_barcode"; | ||
$sql .= ", p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch"; | ||
$sql .= ", p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units"; | ||
$sql .= ", p.surface, p.surface_units, p.volume, p.volume_units, p.tosell as product_tosell, p.tobuy as product_tobuy"; | ||
$sql .= ", p.tobatch as product_tobatch, p.stockable_product"; | ||
$sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."commandedet as cd"; | ||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; | ||
$sql .= " WHERE ed.fk_expedition = ".((int) $this->id); | ||
|
@@ -1690,6 +1692,7 @@ public function fetch_lines() | |
|
||
$line->fk_expedition = $this->id; // id of parent | ||
|
||
$line->stockable_product = $obj->stockable_product; | ||
$line->product_type = $obj->product_type; | ||
$line->fk_product = $obj->fk_product; | ||
$line->fk_product_type = $obj->fk_product_type; | ||
|
@@ -1717,8 +1720,9 @@ public function fetch_lines() | |
$line->surface = $obj->surface; | ||
$line->surface_units = $obj->surface_units; | ||
$line->volume = $obj->volume; | ||
$line->volume_units = $obj->volume_units; | ||
$line->fk_unit = $obj->fk_unit; | ||
$line->volume_units = $obj->volume_units; | ||
$line->stockable_product = $obj->stockable_product; | ||
$line->fk_unit = $obj->fk_unit; | ||
|
||
$line->pa_ht = $obj->pa_ht; | ||
|
||
|
@@ -2829,6 +2833,13 @@ class ExpeditionLigne extends CommonObjectLine | |
public $volume; | ||
public $volume_units; | ||
|
||
/** | ||
* 0=This service or product is not managed in stock, 1=This service or product is managed in stock | ||
* | ||
* @var boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @var int |
||
*/ | ||
public $stockable_product = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. public $stockable_product = 1; |
||
|
||
// Invoicing | ||
public $remise_percent; | ||
public $tva_tx; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If product is not stockable, we have no reason to manage some warehouses.
The "passing test" should be move by changing the test that is blocking later to take into account product status.