|
@@ -2056,6 +2056,8 @@ class CommandeFournisseur extends CommonOrder
|
|
|
|
|
|
$now = dol_now();
|
|
|
|
|
|
+ $inventorycode = dol_print_date(dol_now(), 'dayhourlog');
|
|
|
+
|
|
|
if (($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY || $this->statut == self::STATUS_RECEIVED_COMPLETELY)) {
|
|
|
$this->db->begin();
|
|
|
|
|
@@ -2089,12 +2091,14 @@ 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);
|
|
|
+
|
|
|
// 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);
|
|
|
+ $result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch, $inventorycode);
|
|
|
}
|
|
|
+
|
|
|
if ($result < 0) {
|
|
|
$this->error = $mouv->error;
|
|
|
$this->errors = $mouv->errors;
|