Fix set origin.

This commit is contained in:
Laurent Destailleur 2021-10-12 12:04:43 +02:00
parent 791a7206ee
commit eb73da5abc
3 changed files with 7 additions and 3 deletions

View File

@ -382,7 +382,9 @@ class Mos extends DolibarrApi
if (!$error && $value["fk_warehouse"] > 0) {
// Record stock movement
$id_product_batch = 0;
$stockmove->origin = $this->mo;
$stockmove->setOrigin($this->mo->element, $this->mo->id);
if ($qtytoprocess >= 0) {
$moline = new MoLine($this->db);
$moline->fk_mo = $this->mo->id;

View File

@ -211,7 +211,8 @@ if (empty($reshook)) {
if (!$error && GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0) {
// Record stock movement
$id_product_batch = 0;
$stockmove->origin = $object;
$stockmove->setOrigin($object->element, $object->id);
if ($qtytoprocess >= 0) {
$idstockmove = $stockmove->livraison($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement);
} else {

View File

@ -109,7 +109,7 @@ if ($action == 'cancel_record' && $permissiontoadd) {
if ($action == 'update' && !empty($user->rights->stock->mouvement->creer)) {
$stockmovment = new MouvementStock($db);
$stockmovment->origin = $object;
$stockmovment->setOrigin($object->element, $object->id);
$db->begin();
@ -117,6 +117,7 @@ if ($action == 'update' && !empty($user->rights->stock->mouvement->creer)) {
$sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated';
$sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id';
$sql .= ' WHERE id.fk_inventory = '.((int) $object->id);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);