Compare commits

...

1 Commits

Author SHA1 Message Date
Laurent Destailleur
4f33194b17 Revert "NEW : allow to save stocks as 0 on a stock movement. (#36812)"
This reverts commit 5662bfad31.
2026-01-10 18:21:30 +01:00
2 changed files with 3 additions and 5 deletions

View File

@@ -656,7 +656,7 @@ class MouvementStock extends CommonObject
}
}
if (empty($donotcleanemptylines) && !getDolGlobalInt('STOCK_MOVEMENT_FORCE_DO_NOT_CLEAN_EMPTY_LINES')) {
if (empty($donotcleanemptylines)) {
// 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 ".$this->db->prefix()."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".$this->db->prefix()."product_batch as pb)";

View File

@@ -1052,10 +1052,8 @@ if (!$variants || getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PA
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
$sql .= " ".MAIN_DB_PREFIX."product_stock as ps";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product";
$sql .= " WHERE ps.fk_entrepot = e.rowid";
if (!getDolGlobalInt('STOCK_MOVEMENT_FORCE_DO_NOT_CLEAN_EMPTY_LINES')) {
$sql .= " AND ps.reel != 0";
}
$sql .= " WHERE ps.reel != 0";
$sql .= " AND ps.fk_entrepot = e.rowid";
$sql .= " AND e.entity IN (".getEntity('stock').")";
$sql .= " AND ps.fk_product = ".((int) $object->id);
$sql .= " ORDER BY e.ref";