Fix #18895 Fix negative stock correction

If people use a negative number as input, I think we can assume they want to delete units. It will now set the movement to 1 if the number is negative and 'add' was selected.

For each negative number we now multiply this number by -1, to make it a positive number again.
This commit is contained in:
xgerhard 2021-10-05 00:25:52 +02:00
parent 9617bbb463
commit e44c3a46e1

View File

@ -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 *= -1;
}
$op[0] = "+".trim($nbpiece);
$op[1] = "-".trim($nbpiece);
@ -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 *= -1;
}
$op[0] = "+".trim($nbpiece);
$op[1] = "-".trim($nbpiece);