diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 0c7b9d46f3c..41e0487e973 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -2743,7 +2743,7 @@ class Form
public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '')
{
// phpcs:enable
- global $langs, $conf, $db;
+ global $langs, $conf, $db, $user;
$out = '';
$outarray = array();
@@ -2757,6 +2757,9 @@ class Form
}
$sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type,";
+ if (!empty($conf->stock->enabled)) {
+ $sql .= " p.stock,";
+ }
$sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
$sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,";
$sql .= " pfp.supplier_reputation";
@@ -2974,6 +2977,43 @@ class Form
}
}
+ if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)))
+ {
+ if (!empty($user->rights->stock->lire)) {
+ $optlabel .= ' - '.$langs->trans("Stock").':'.$objp->stock;
+
+ if ($objp->stock > 0) {
+ $outval .= ' - ';
+ } elseif ($objp->stock <= 0) {
+ $outval .= ' - ';
+ }
+ $outval .= $langs->transnoentities("Stock").':'.$objp->stock;
+ $outval .= '';
+ if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation
+ {
+ $langs->load("stocks");
+
+ $tmpproduct = new Product($this->db);
+ $tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after)
+ $tmpproduct->load_virtual_stock();
+ $virtualstock = $tmpproduct->stock_theorique;
+
+ $optlabel .= ' - '.$langs->trans("VirtualStock").':'.$virtualstock;
+
+ $outval .= ' - '.$langs->transnoentities("VirtualStock").':';
+ if ($virtualstock > 0) {
+ $outval .= '';
+ } elseif ($virtualstock <= 0) {
+ $outval .= '';
+ }
+ $outval .= $virtualstock;
+ $outval .= '';
+
+ unset($tmpproduct);
+ }
+ }
+ }
+
$opt = '