Add stock availability reading.
This commit is contained in:
parent
108abbf22c
commit
d45dfe8ee7
@ -149,18 +149,25 @@ class modStock extends DolibarrModules
|
|||||||
$this->rights[4][4] = 'mouvement';
|
$this->rights[4][4] = 'mouvement';
|
||||||
$this->rights[4][5] = 'creer';
|
$this->rights[4][5] = 'creer';
|
||||||
|
|
||||||
$this->rights[5][0] = 1011;
|
$this->rights[5][0] = 1006;
|
||||||
$this->rights[5][1] = 'inventoryReadPermission'; // Permission label
|
$this->rights[5][1] = 'stockAvailabilityReadPermission';
|
||||||
$this->rights[5][3] = 0; // Permission by default for new user (0/1)
|
$this->rights[5][3] = 0;
|
||||||
$this->rights[5][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
$this->rights[5][4] = 'availability';
|
||||||
$this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
$this->rights[5][5] = 'read';
|
||||||
|
|
||||||
$this->rights[6][0] = 1012;
|
$this->rights[6][0] = 1011;
|
||||||
$this->rights[6][1] = 'inventoryCreatePermission'; // Permission label
|
$this->rights[6][1] = 'inventoryReadPermission'; // Permission label
|
||||||
$this->rights[6][3] = 0; // Permission by default for new user (0/1)
|
$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][4] = 'inventory_advance'; // 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[6][5] = 'read'; // 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) {
|
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
|
||||||
$this->rights[8][0] = 1014;
|
$this->rights[8][0] = 1014;
|
||||||
$this->rights[8][1] = 'inventoryValidatePermission'; // Permission label
|
$this->rights[8][1] = 'inventoryValidatePermission'; // Permission label
|
||||||
|
|||||||
@ -256,4 +256,5 @@ MakeMovementsAndClose=Generate movements and close
|
|||||||
AutofillWithExpected=Fill real quantity with expected quantity
|
AutofillWithExpected=Fill real quantity with expected quantity
|
||||||
ShowAllBatchByDefault=By default, show batch details on product "stock" tab
|
ShowAllBatchByDefault=By default, show batch details on product "stock" tab
|
||||||
CollapseBatchDetailHelp=You can set batch detail default display in stocks module configuration
|
CollapseBatchDetailHelp=You can set batch detail default display in stocks module configuration
|
||||||
FieldCannotBeNegative=Field "%s" cannot be negative
|
FieldCannotBeNegative=Field "%s" cannot be negative
|
||||||
|
stockAvailabilityReadPermission=See stock availability
|
||||||
|
|||||||
@ -257,3 +257,4 @@ 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
|
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
|
CollapseBatchDetailHelp=You can set batch detail default display in stocks module configuration
|
||||||
FieldCannotBeNegative=Le champ "%s" ne peut pas être négatif
|
FieldCannotBeNegative=Le champ "%s" ne peut pas être négatif
|
||||||
|
stockAvailabilityReadPermission=Voir la disponibilité des stocks
|
||||||
|
|||||||
@ -1617,11 +1617,14 @@ class Products extends DolibarrApi
|
|||||||
$combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id);
|
$combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id);
|
||||||
$combinations[$key] = $this->_cleanObjectDatas($combinations[$key]);
|
$combinations[$key] = $this->_cleanObjectDatas($combinations[$key]);
|
||||||
|
|
||||||
if ($includestock==1) {
|
if ($includestock==1 && (DolibarrApiAccess::$user->rights->stock->lire || DolibarrApiAccess::$user->rights->stock->availability->read)) {
|
||||||
$productModel = new Product($this->db);
|
$productModel = new Product($this->db);
|
||||||
$productModel->fetch((int) $combination->fk_product_child);
|
$productModel->fetch((int) $combination->fk_product_child);
|
||||||
$productModel->load_stock();
|
$productModel->load_stock();
|
||||||
$combinations[$key]->stock_warehouse = $this->_cleanObjectDatas($productModel)->stock_warehouse;
|
|
||||||
|
if(DolibarrApiAccess::$user->rights->stock->lire){ // full warehouse info needs full stock reading perms
|
||||||
|
$combinations[$key]->stock_warehouse = $this->_cleanObjectDatas($productModel)->stock_warehouse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1859,7 +1862,7 @@ class Products extends DolibarrApi
|
|||||||
public function getStock($id, $selected_warehouse_id = null)
|
public function getStock($id, $selected_warehouse_id = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!DolibarrApiAccess::$user->rights->produit->lire) {
|
if (!DolibarrApiAccess::$user->rights->produit->lire || !DolibarrApiAccess::$user->rights->stock->lire) { // full product and stock access required for detailed stock info
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1945,6 +1948,18 @@ class Products extends DolibarrApi
|
|||||||
|
|
||||||
unset($object->supplierprices); // Mut use another API to get them
|
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;
|
return $object;
|
||||||
}
|
}
|
||||||
@ -2008,7 +2023,7 @@ class Products extends DolibarrApi
|
|||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($includestockdata) {
|
if ($includestockdata && (DolibarrApiAccess::$user->rights->stock->lire || DolibarrApiAccess::$user->rights->stock->availability->read)) {
|
||||||
$this->product->load_stock();
|
$this->product->load_stock();
|
||||||
|
|
||||||
if (is_array($this->product->stock_warehouse)) {
|
if (is_array($this->product->stock_warehouse)) {
|
||||||
|
|||||||
@ -208,6 +208,22 @@ class Product extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public $stock_theorique;
|
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
|
* Cost price
|
||||||
*
|
*
|
||||||
@ -5172,6 +5188,8 @@ class Product extends CommonObject
|
|||||||
$this->stock_reel = 0;
|
$this->stock_reel = 0;
|
||||||
$this->stock_warehouse = array();
|
$this->stock_warehouse = array();
|
||||||
$this->stock_theorique = 0;
|
$this->stock_theorique = 0;
|
||||||
|
$this->stock_real_available = false;
|
||||||
|
$this->stock_virtual_available = false;
|
||||||
|
|
||||||
// Set filter on warehouse status
|
// Set filter on warehouse status
|
||||||
$warehouseStatus = array();
|
$warehouseStatus = array();
|
||||||
@ -5221,6 +5239,8 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|
||||||
|
$this->stock_real_available = ($this->stock_reel > 0) ? true : false;
|
||||||
|
|
||||||
if (!preg_match('/novirtual/', $option)) {
|
if (!preg_match('/novirtual/', $option)) {
|
||||||
$this->load_virtual_stock($includedraftpoforvirtual); // This also load all arrays stats_xxx...
|
$this->load_virtual_stock($includedraftpoforvirtual); // This also load all arrays stats_xxx...
|
||||||
}
|
}
|
||||||
@ -5344,6 +5364,8 @@ class Product extends CommonObject
|
|||||||
$this->stock_theorique = $hookmanager->resArray['stock_theorique'];
|
$this->stock_theorique = $hookmanager->resArray['stock_theorique'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->stock_virtual_available = ($this->stock_theorique > 0) ? true : false;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user