Fix: The origin of the stock movement is not being recorded

This commit is contained in:
Ferran Marcet
2022-03-22 13:46:55 +01:00
parent dd38f6c35b
commit ccf8b01020
7 changed files with 26 additions and 9 deletions

View File

@@ -10,7 +10,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016-2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
@@ -518,6 +518,7 @@ class Commande extends CommonOrder
if ($this->lines[$i]->fk_product > 0) {
$mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
$mouvP->setOrigin($this->element, $this->id);
// We decrement stock of product (and sub-products)
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr", $num));
if ($result < 0) {
@@ -645,6 +646,7 @@ class Commande extends CommonOrder
if ($this->lines[$i]->fk_product > 0) {
$mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
$mouvP->setOrigin($this->element, $this->id);
// We increment stock of product (and sub-products)
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr", $this->ref));
if ($result < 0) {
@@ -823,6 +825,7 @@ class Commande extends CommonOrder
for ($i = 0; $i < $num; $i++) {
if ($this->lines[$i]->fk_product > 0) {
$mouvP = new MouvementStock($this->db);
$mouvP->setOrigin($this->element, $this->id);
// We increment stock of product (and sub-products)
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderCanceledInDolibarr", $this->ref)); // price is 0, we don't want WAP to be changed
if ($result < 0) {