Merge pull request #20811 from ibuiv/allow-retrocession2

add hidden option SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDE…
This commit is contained in:
Laurent Destailleur 2022-05-10 11:11:13 +02:00 committed by GitHub
commit 44e7496ef3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -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;

View File

@ -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;
}