Merge pull request #13620 from atm-quentin/FIX_draftordered_replenish
FIX draftordered replenish virtual stock
This commit is contained in:
commit
7f746af10e
@ -4687,7 +4687,7 @@ class Product extends CommonObject
|
|||||||
* @return int < 0 if KO, > 0 if OK
|
* @return int < 0 if KO, > 0 if OK
|
||||||
* @see load_virtual_stock(), loadBatchInfo()
|
* @see load_virtual_stock(), loadBatchInfo()
|
||||||
*/
|
*/
|
||||||
public function load_stock($option = '')
|
public function load_stock($option = '', $includedraftpoforvirtual = null)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf;
|
global $conf;
|
||||||
@ -4740,7 +4740,7 @@ class Product extends CommonObject
|
|||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|
||||||
if (!preg_match('/novirtual/', $option)) {
|
if (!preg_match('/novirtual/', $option)) {
|
||||||
$this->load_virtual_stock(); // This also load stats_commande_fournisseur, ...
|
$this->load_virtual_stock($includedraftpoforvirtual); // This also load stats_commande_fournisseur, ...
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -4761,7 +4761,7 @@ class Product extends CommonObject
|
|||||||
* @return int < 0 if KO, > 0 if OK
|
* @return int < 0 if KO, > 0 if OK
|
||||||
* @see load_stock(), loadBatchInfo()
|
* @see load_stock(), loadBatchInfo()
|
||||||
*/
|
*/
|
||||||
public function load_virtual_stock()
|
public function load_virtual_stock($includedraftpoforvirtual = null)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf, $hookmanager, $action;
|
global $conf, $hookmanager, $action;
|
||||||
@ -4793,19 +4793,25 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
if (!empty($conf->fournisseur->enabled))
|
if (!empty($conf->fournisseur->enabled))
|
||||||
{
|
{
|
||||||
$result = $this->load_stats_commande_fournisseur(0, '1,2,3,4', 1);
|
$filterStatus = '1,2,3,4';
|
||||||
|
if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus;
|
||||||
|
$result = $this->load_stats_commande_fournisseur(0, $filterStatus, 1);
|
||||||
if ($result < 0) dol_print_error($this->db, $this->error);
|
if ($result < 0) dol_print_error($this->db, $this->error);
|
||||||
$stock_commande_fournisseur = $this->stats_commande_fournisseur['qty'];
|
$stock_commande_fournisseur = $this->stats_commande_fournisseur['qty'];
|
||||||
}
|
}
|
||||||
if (!empty($conf->fournisseur->enabled) && empty($conf->reception->enabled))
|
if (!empty($conf->fournisseur->enabled) && empty($conf->reception->enabled))
|
||||||
{
|
{
|
||||||
$result = $this->load_stats_reception(0, '4', 1);
|
$filterStatus = '4';
|
||||||
|
if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus;
|
||||||
|
$result = $this->load_stats_reception(0, $filterStatus, 1);
|
||||||
if ($result < 0) dol_print_error($this->db, $this->error);
|
if ($result < 0) dol_print_error($this->db, $this->error);
|
||||||
$stock_reception_fournisseur = $this->stats_reception['qty'];
|
$stock_reception_fournisseur = $this->stats_reception['qty'];
|
||||||
}
|
}
|
||||||
if (!empty($conf->fournisseur->enabled) && !empty($conf->reception->enabled))
|
if (!empty($conf->fournisseur->enabled) && !empty($conf->reception->enabled))
|
||||||
{
|
{
|
||||||
$result = $this->load_stats_reception(0, '4', 1); // Use same tables than when module reception is not used.
|
$filterStatus = '4';
|
||||||
|
if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus;
|
||||||
|
$result = $this->load_stats_reception(0, $filterStatus, 1); // Use same tables than when module reception is not used.
|
||||||
if ($result < 0) dol_print_error($this->db, $this->error);
|
if ($result < 0) dol_print_error($this->db, $this->error);
|
||||||
$stock_reception_fournisseur = $this->stats_reception['qty'];
|
$stock_reception_fournisseur = $this->stats_reception['qty'];
|
||||||
}
|
}
|
||||||
@ -4847,7 +4853,7 @@ class Product extends CommonObject
|
|||||||
$hookmanager = new HookManager($this->db);
|
$hookmanager = new HookManager($this->db);
|
||||||
}
|
}
|
||||||
$hookmanager->initHooks(array('productdao'));
|
$hookmanager->initHooks(array('productdao'));
|
||||||
$parameters = array('id'=>$this->id);
|
$parameters = array('id'=>$this->id, 'includedraftpoforvirtual' => $includedraftpoforvirtual);
|
||||||
// Note that $action and $object may have been modified by some hooks
|
// Note that $action and $object may have been modified by some hooks
|
||||||
$reshook = $hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action);
|
$reshook = $hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action);
|
||||||
if ($reshook > 0) $this->stock_theorique = $hookmanager->resArray['stock_theorique'];
|
if ($reshook > 0) $this->stock_theorique = $hookmanager->resArray['stock_theorique'];
|
||||||
|
|||||||
@ -648,7 +648,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
|
|||||||
if (!empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0)
|
if (!empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0)
|
||||||
{
|
{
|
||||||
$prod->fetch($objp->rowid);
|
$prod->fetch($objp->rowid);
|
||||||
$prod->load_stock('warehouseopen, warehouseinternal');
|
$prod->load_stock('warehouseopen, warehouseinternal', $draftchecked);
|
||||||
|
|
||||||
// Multilangs
|
// Multilangs
|
||||||
if (!empty($conf->global->MAIN_MULTILANGS))
|
if (!empty($conf->global->MAIN_MULTILANGS))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user