Fix: Serious pb with loading stocks. If we use product->stock_reel or
product->stock_warehoure[], we must call product->load_stock() after the product->fetch().
This commit is contained in:
parent
df779086a6
commit
da569ea8d4
@ -495,6 +495,7 @@ if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($objp->fk_product);
|
||||
$product->load_stock();
|
||||
}
|
||||
|
||||
if ($objp->fk_product > 0 && $type == 0 && ! empty($conf->stock->enabled))
|
||||
|
||||
@ -1224,6 +1224,7 @@ class Product extends CommonObject
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
|
||||
// multilangs
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs();
|
||||
|
||||
@ -1347,10 +1348,11 @@ class Product extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// We should not load stock at each fetch
|
||||
// We should not load stock at each fetch. If someone need stock, he must call load_stock after fetch.
|
||||
//$res=$this->load_stock();
|
||||
|
||||
return $res;
|
||||
//return $res;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -81,7 +81,8 @@ class MouvementStock
|
||||
dol_print_error('',"Failed to fetch product");
|
||||
return -1;
|
||||
}
|
||||
|
||||
$product->load_stock();
|
||||
|
||||
// Define if we must make the stock change (If product type is a service or if stock is used also for services)
|
||||
$movestock=0;
|
||||
if ($product->type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock=1;
|
||||
|
||||
@ -207,9 +207,9 @@ $formproduct=new FormProduct($db);
|
||||
if ($id > 0 || $ref)
|
||||
{
|
||||
$product = new Product($db);
|
||||
if ($ref) $result = $product->fetch('',$ref);
|
||||
if ($id > 0) $result = $product->fetch($id);
|
||||
|
||||
$result = $product->fetch($id,$ref);
|
||||
$product->load_stock();
|
||||
|
||||
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
|
||||
llxHeader("",$langs->trans("CardProduct".$product->type),$help_url);
|
||||
|
||||
|
||||
@ -333,8 +333,11 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='')
|
||||
{
|
||||
$product=new Product($db);
|
||||
$result=$product->fetch($id,$ref,$ref_ext);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$product->load_stock();
|
||||
|
||||
$dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output);
|
||||
$pdir = get_exdir($product->id,2) . $product->id ."/photos/";
|
||||
$dir = $dir . '/'. $pdir;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user