diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php
index 6b2c626da39..a5da8d7230f 100644
--- a/htdocs/admin/stock.php
+++ b/htdocs/admin/stock.php
@@ -87,6 +87,9 @@ if($action)
if($action == 'STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT') {
$res = dolibarr_set_const($db, "STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", GETPOST('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT','alpha'),'chaine',0,'',$conf->entity);
}
+ if($action == 'INDEPENDANT_SUBPRODUCT_STOCK') {
+ $res = dolibarr_set_const($db, "INDEPENDANT_SUBPRODUCT_STOCK", GETPOST('INDEPENDANT_SUBPRODUCT_STOCK','alpha'),'chaine',0,'',$conf->entity);
+ }
if (! $res > 0) $error++;
@@ -339,9 +342,27 @@ print '';
print "\n";
print "\n";
print '
';
-print '';
-print '
';
+if($conf->global->PRODUIT_SOUSPRODUITS) {
+
+ $var=!$var;
+
+ print "
";
+ print '| '.$langs->trans("IndependantSubProductStock").' | ';
+
+ print '';
+ print "';
+ print " | \n";
+ print "
\n";
+
+}
+
+print '';
llxFooter();
diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang
index 10fcf353fd4..7025176c9f1 100644
--- a/htdocs/langs/en_US/stocks.lang
+++ b/htdocs/langs/en_US/stocks.lang
@@ -47,6 +47,7 @@ PMPValue=Weighted average price
PMPValueShort=WAP
EnhancedValueOfWarehouses=Warehouses value
UserWarehouseAutoCreate=Create a warehouse automatically when creating a user
+IndependantSubProductStock=Product stock and subproduct stock are independant
QtyDispatched=Quantity dispatched
QtyDispatchedShort=Qty dispatched
QtyToDispatchShort=Qty to dispatch
diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php
index f175d75db6f..4cea2b7621c 100644
--- a/htdocs/product/stock/class/mouvementstock.class.php
+++ b/htdocs/product/stock/class/mouvementstock.class.php
@@ -292,7 +292,7 @@ class MouvementStock extends CommonObject
}
// Add movement for sub products (recursive call)
- if (! $error && ! empty($conf->global->PRODUIT_SOUSPRODUITS))
+ if (! $error && ! empty($conf->global->PRODUIT_SOUSPRODUITS) && empty($conf->global->INDEPENDANT_SUBPRODUCT_STOCK))
{
$error = $this->_createSubProduct($user, $fk_product, $entrepot_id, $qty, $type, 0, $label, $inventorycode); // we use 0 as price, because pmp is not changed for subproduct
}