Merge pull request #20811 from ibuiv/allow-retrocession2
add hidden option SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDE…
This commit is contained in:
commit
44e7496ef3
@ -2084,7 +2084,12 @@ class CommandeFournisseur extends CommonOrder
|
||||
// $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on)
|
||||
$mouv->origin = &$this;
|
||||
$mouv->setOrigin($this->element, $this->id);
|
||||
$result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch);
|
||||
// Method change if qty < 0
|
||||
if (!empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN) && $qty < 0) {
|
||||
$result = $mouv->livraison($user, $product, $entrepot, $qty*(-1), $price, $comment, $now, $eatby, $sellby, $batch);
|
||||
} else {
|
||||
$result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch);
|
||||
}
|
||||
if ($result < 0) {
|
||||
$this->error = $mouv->error;
|
||||
$this->errors = $mouv->errors;
|
||||
|
||||
@ -802,7 +802,7 @@ if ($id > 0 || !empty($ref)) {
|
||||
$nbfreeproduct++;
|
||||
} else {
|
||||
$remaintodispatch = price2num($objp->qty - ((float) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched
|
||||
if ($remaintodispatch < 0) {
|
||||
if ($remaintodispatch < 0 && empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN)) {
|
||||
$remaintodispatch = 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user