From 02d59cce5a25ba2ced2d01924088b111734c57ce Mon Sep 17 00:00:00 2001 From: Gauthier Date: Mon, 16 Feb 2015 16:06:50 +0100 Subject: [PATCH] NEW : Product stock and subproduct stock are independant --- htdocs/admin/stock.php | 25 +++++++++++++++++-- htdocs/langs/en_US/stocks.lang | 1 + .../stock/class/mouvementstock.class.php | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) 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 ''; + print ""; + print $form->selectyesno("INDEPENDANT_SUBPRODUCT_STOCK",$conf->global->INDEPENDANT_SUBPRODUCT_STOCK,1); + 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 9c7a6f7acbd..275e8ba30a9 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 }