Fix: add possibility to force date of stock movement
This commit is contained in:
parent
4eeddcbb3b
commit
5f02432d90
@ -485,7 +485,7 @@ class Expedition extends CommonObject
|
|||||||
// If stock increment is done on sending (recommanded choice)
|
// If stock increment is done on sending (recommanded choice)
|
||||||
if (! $error && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT)
|
if (! $error && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php";
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
||||||
|
|
||||||
$langs->load("agenda");
|
$langs->load("agenda");
|
||||||
|
|
||||||
|
|||||||
@ -44,26 +44,28 @@ class MouvementStock
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a movement of stock (in one direction only)
|
* Add a movement of stock (in one direction only)
|
||||||
* @param user User object
|
*
|
||||||
* @param fk_product Id of product
|
* @param User $user User object
|
||||||
* @param entrepot_id Id of warehouse
|
* @param int $fk_product Id of product
|
||||||
* @param qty Qty of movement (can be <0 or >0)
|
* @param int $entrepot_id Id of warehouse
|
||||||
* @param type Direction of movement:
|
* @param int $qty Qty of movement (can be <0 or >0)
|
||||||
* 0=input (stock increase after stock transfert), 1=output (stock decrease after stock transfer),
|
* @param int $type Direction of movement:
|
||||||
* 2=output (stock decrease), 3=input (stock increase)
|
* 0=input (stock increase after stock transfert), 1=output (stock decrease after stock transfer),
|
||||||
* @param price Unit price HT of product
|
* 2=output (stock decrease), 3=input (stock increase)
|
||||||
* @param label Label of stock movement
|
* @param int $price Unit price HT of product
|
||||||
* @return int <0 if KO, >0 if OK
|
* @param string $label Label of stock movement
|
||||||
|
* @param string $datem Force date of movement
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='')
|
function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='', $datem='')
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
dol_syslog("MouvementStock::_create start userid=$user->id, fk_product=$fk_product, warehouse=$entrepot_id, qty=$qty, type=$type, price=$price label=$label");
|
dol_syslog("MouvementStock::_create start userid=$user->id, fk_product=$fk_product, warehouse=$entrepot_id, qty=$qty, type=$type, price=$price label=$label");
|
||||||
|
|
||||||
$now=dol_now();
|
$now=(! empty($datem) ? $datem : dol_now());
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
@ -305,11 +307,12 @@ class MouvementStock
|
|||||||
* @param int $qty Quantity
|
* @param int $qty Quantity
|
||||||
* @param int $price Price
|
* @param int $price Price
|
||||||
* @param string $label Label of stock movement
|
* @param string $label Label of stock movement
|
||||||
|
* @param string $datem Force date of movement
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='')
|
function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='', $datem='')
|
||||||
{
|
{
|
||||||
return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label);
|
return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, $datem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user