diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 89bc7c35423..3494cb684dc 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -149,25 +149,18 @@ class modStock extends DolibarrModules $this->rights[4][4] = 'mouvement'; $this->rights[4][5] = 'creer'; - $this->rights[5][0] = 1006; - $this->rights[5][1] = 'stockAvailabilityReadPermission'; - $this->rights[5][3] = 0; - $this->rights[5][4] = 'availability'; - $this->rights[5][5] = 'read'; + $this->rights[5][0] = 1011; + $this->rights[5][1] = 'inventoryReadPermission'; // Permission label + $this->rights[5][3] = 0; // Permission by default for new user (0/1) + $this->rights[5][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[6][0] = 1011; - $this->rights[6][1] = 'inventoryReadPermission'; // Permission label + $this->rights[6][0] = 1012; + $this->rights[6][1] = 'inventoryCreatePermission'; // Permission label $this->rights[6][3] = 0; // Permission by default for new user (0/1) $this->rights[6][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[6][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[6][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[7][0] = 1012; - $this->rights[7][1] = 'inventoryCreatePermission'; // Permission label - $this->rights[7][3] = 0; // Permission by default for new user (0/1) - $this->rights[7][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[7][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { $this->rights[8][0] = 1014; $this->rights[8][1] = 'inventoryValidatePermission'; // Permission label diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index d07a86f7354..f1bfe186bdf 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -256,5 +256,4 @@ MakeMovementsAndClose=Generate movements and close AutofillWithExpected=Fill real quantity with expected quantity ShowAllBatchByDefault=By default, show batch details on product "stock" tab CollapseBatchDetailHelp=You can set batch detail default display in stocks module configuration -FieldCannotBeNegative=Field "%s" cannot be negative -stockAvailabilityReadPermission=See stock availability +FieldCannotBeNegative=Field "%s" cannot be negative \ No newline at end of file diff --git a/htdocs/langs/fr_FR/stocks.lang b/htdocs/langs/fr_FR/stocks.lang index f91b24ad1db..68003ebe864 100644 --- a/htdocs/langs/fr_FR/stocks.lang +++ b/htdocs/langs/fr_FR/stocks.lang @@ -257,4 +257,3 @@ AutofillWithExpected=Remplir la quantité réelle avec la quantité prévue ShowAllBatchByDefault=Par défaut, afficher les détails des lots sur l'onglet "stock" du produit CollapseBatchDetailHelp=You can set batch detail default display in stocks module configuration FieldCannotBeNegative=Le champ "%s" ne peut pas être négatif -stockAvailabilityReadPermission=Voir la disponibilité des stocks diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c66bb7b43ed..2e0d21b0456 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1617,14 +1617,11 @@ class Products extends DolibarrApi $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); $combinations[$key] = $this->_cleanObjectDatas($combinations[$key]); - if ($includestock==1 && (DolibarrApiAccess::$user->rights->stock->lire || DolibarrApiAccess::$user->rights->stock->availability->read)) { + if ($includestock==1) { $productModel = new Product($this->db); $productModel->fetch((int) $combination->fk_product_child); $productModel->load_stock(); - - if(DolibarrApiAccess::$user->rights->stock->lire){ // full warehouse info needs full stock reading perms - $combinations[$key]->stock_warehouse = $this->_cleanObjectDatas($productModel)->stock_warehouse; - } + $combinations[$key]->stock_warehouse = $this->_cleanObjectDatas($productModel)->stock_warehouse; } } @@ -1862,7 +1859,7 @@ class Products extends DolibarrApi public function getStock($id, $selected_warehouse_id = null) { - if (!DolibarrApiAccess::$user->rights->produit->lire || !DolibarrApiAccess::$user->rights->stock->lire) { // full product and stock access required for detailed stock info + if (!DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); } @@ -1948,18 +1945,6 @@ class Products extends DolibarrApi unset($object->supplierprices); // Mut use another API to get them - // remove stock info if no stock read rights - if(!DolibarrApiAccess::$user->rights->stock->lire){ - unset($object->stock_reel); - unset($object->stock_theorique); - unset($object->stock_warehouse); - } - - // remove stock availability info if no stock read rights or availability read rights - if((!DolibarrApiAccess::$user->rights->stock->availability->read) && (!DolibarrApiAccess::$user->rights->stock->lire)){ - unset($object->stock_real_available); - unset($object->stock_virtual_available); - } return $object; } @@ -2023,7 +2008,7 @@ class Products extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if ($includestockdata && (DolibarrApiAccess::$user->rights->stock->lire || DolibarrApiAccess::$user->rights->stock->availability->read)) { + if ($includestockdata) { $this->product->load_stock(); if (is_array($this->product->stock_warehouse)) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d12b80b0b96..3029f439267 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -208,22 +208,6 @@ class Product extends CommonObject */ public $stock_theorique; - /** - * Stock real available - * - * @var bool - */ - public $stock_real_available = false; - - /** - * Stock virtual available - * - * @var bool - */ - public $stock_virtual_available = false; - - - /** * Cost price * @@ -5187,8 +5171,6 @@ class Product extends CommonObject $this->stock_reel = 0; $this->stock_warehouse = array(); $this->stock_theorique = 0; - $this->stock_real_available = false; - $this->stock_virtual_available = false; // Set filter on warehouse status $warehouseStatus = array(); @@ -5238,8 +5220,6 @@ class Product extends CommonObject } $this->db->free($result); - $this->stock_real_available = ($this->stock_reel > 0) ? true : false; - if (!preg_match('/novirtual/', $option)) { $this->load_virtual_stock($includedraftpoforvirtual); // This also load all arrays stats_xxx... } @@ -5363,8 +5343,6 @@ class Product extends CommonObject $this->stock_theorique = $hookmanager->resArray['stock_theorique']; } - $this->stock_virtual_available = ($this->stock_theorique > 0) ? true : false; - return 1; }