NEW manage virtual stock at future date

This commit is contained in:
ptibogxiv 2022-08-07 19:37:15 +02:00 committed by GitHub
parent f56abb1e5f
commit 6ff002405e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -253,7 +253,7 @@ class Products extends DolibarrApi
if (!$ids_only) {
$product_static = new Product($this->db);
if ($product_static->fetch($obj->rowid)) {
if ($includestockdata && DolibarrApiAccess::$user->rights->stock->lire) {
if (!empty($includestockdata) && DolibarrApiAccess::$user->rights->stock->lire) {
$product_static->load_stock();
if (is_array($product_static->stock_warehouse)) {
@ -1644,10 +1644,10 @@ 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) {
if (!empty($includestock) && DolibarrApiAccess::$user->rights->stock->lire) {
$productModel = new Product($this->db);
$productModel->fetch((int) $combination->fk_product_child);
$productModel->load_stock();
$productModel->load_stock($includestock);
$combinations[$key]->stock_warehouse = $this->_cleanObjectDatas($productModel)->stock_warehouse;
}
}
@ -2040,8 +2040,8 @@ class Products extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if ($includestockdata && DolibarrApiAccess::$user->rights->stock->lire) {
$this->product->load_stock();
if (!empty($includestockdata) && DolibarrApiAccess::$user->rights->stock->lire) {
$this->product->load_stock($includestockdata);
if (is_array($this->product->stock_warehouse)) {
foreach ($this->product->stock_warehouse as $keytmp => $valtmp) {