This commit is contained in:
Laurent Destailleur 2022-06-25 04:06:18 +02:00
parent 192510316b
commit 380cae761a
3 changed files with 14 additions and 6 deletions

View File

@ -2155,7 +2155,7 @@ elseif ($id || $ref)
//if ($filter) $sql.= $filter; //if ($filter) $sql.= $filter;
$sql .= " ORDER BY obj.fk_product"; $sql .= " ORDER BY obj.fk_product";
dol_syslog("get list of shipment lines", LOG_DEBUG); dol_syslog("expedition/card.php get list of shipment lines", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {

View File

@ -801,6 +801,12 @@ class Expedition extends CommonObject
} }
} }
} }
// If stock is now 0, we can remove entry into llx_product_stock, but only if there is no child lines into llx_product_batch (detail of batch, because we can imagine
// having a lot1/qty=X and lot2/qty=-X, so 0 but we must not loose repartition of different lot.
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)";
$resql = $this->db->query($sql);
// We do not test error, it can fails if there is child in batch details
} }
else else
{ {

View File

@ -571,11 +571,13 @@ class MouvementStock extends CommonObject
} }
} }
// If stock is now 0, we can remove entry into llx_product_stock, but only if there is no child lines into llx_product_batch (detail of batch, because we can imagine if (empty($donotcleanemptyline)) {
// having a lot1/qty=X and lot2/qty=-X, so 0 but we must not loose repartition of different lot. // If stock is now 0, we can remove entry into llx_product_stock, but only if there is no child lines into llx_product_batch (detail of batch, because we can imagine
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)"; // having a lot1/qty=X and lot2/qty=-X, so 0 but we must not loose repartition of different lot.
$resql = $this->db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)";
// We do not test error, it can fails if there is child in batch details $resql = $this->db->query($sql);
// We do not test error, it can fails if there is child in batch details
}
} }
// Add movement for sub products (recursive call) // Add movement for sub products (recursive call)