Merge pull request #18902 from xgerhard/fix-negative-stock-correction
Fix #18895 Fix negative stock correction
This commit is contained in:
commit
06eb138b47
@ -5111,7 +5111,7 @@ class Product extends CommonObject
|
||||
*
|
||||
* @param User $user user asking change
|
||||
* @param int $id_entrepot id of warehouse
|
||||
* @param double $nbpiece nb of units
|
||||
* @param double $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove)
|
||||
* @param int $movement 0 = add, 1 = remove
|
||||
* @param string $label Label of stock movement
|
||||
* @param double $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed.
|
||||
@ -5129,6 +5129,13 @@ class Product extends CommonObject
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
||||
|
||||
if ($nbpiece < 0) {
|
||||
if (!$movement) {
|
||||
$movement = 1;
|
||||
}
|
||||
$nbpiece = abs($nbpiece);
|
||||
}
|
||||
|
||||
$op[0] = "+".trim($nbpiece);
|
||||
$op[1] = "-".trim($nbpiece);
|
||||
|
||||
@ -5155,7 +5162,7 @@ class Product extends CommonObject
|
||||
*
|
||||
* @param User $user user asking change
|
||||
* @param int $id_entrepot id of warehouse
|
||||
* @param double $nbpiece nb of units
|
||||
* @param double $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove)
|
||||
* @param int $movement 0 = add, 1 = remove
|
||||
* @param string $label Label of stock movement
|
||||
* @param double $price Price to use for stock eval
|
||||
@ -5176,6 +5183,13 @@ class Product extends CommonObject
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
||||
|
||||
if ($nbpiece < 0) {
|
||||
if (!$movement) {
|
||||
$movement = 1;
|
||||
}
|
||||
$nbpiece = abs($nbpiece);
|
||||
}
|
||||
|
||||
$op[0] = "+".trim($nbpiece);
|
||||
$op[1] = "-".trim($nbpiece);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user