From cd9e54b1a2a164ff8ef86dd34020bf7224fc6192 Mon Sep 17 00:00:00 2001 From: omogenot Date: Sun, 20 Oct 2024 00:19:01 +0200 Subject: [PATCH] FIX: Replenishment lib class does not extract data from already received supplier orders (#31440) * Update replenishment.lib.php * Fix wrong table column name from fk_command to fk_element for table receptiondet_batch * use error free getDolGlobalString to access global variable to replace $conf->global access. * Update replenishment.lib.php Fix typo * Update replenishment.lib.php Use getDolGlobalInt instead of getDolGlobalString for numeric constant * Update replenishment.lib.php --------- Co-authored-by: Laurent Destailleur --- htdocs/product/stock/lib/replenishment.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/stock/lib/replenishment.lib.php b/htdocs/product/stock/lib/replenishment.lib.php index ead80f810b8..2bfb14268db 100644 --- a/htdocs/product/stock/lib/replenishment.lib.php +++ b/htdocs/product/stock/lib/replenishment.lib.php @@ -39,7 +39,7 @@ function dolDispatchToDo($order_id) // Count nb of quantity dispatched per product $sql = 'SELECT fk_product, SUM(qty) as qtydispatched FROM '.MAIN_DB_PREFIX.'receptiondet_batch'; - $sql .= ' WHERE fk_commande = '.((int) $order_id); + $sql .= " WHERE fk_element = ".((int) $order_id)." AND element_type = 'supplier_order'"; $sql .= ' GROUP BY fk_product'; $sql .= ' ORDER by fk_product'; $resql = $db->query($sql); @@ -119,9 +119,9 @@ function ordered($product_id) $sql .= ' '.MAIN_DB_PREFIX.'commande_fournisseurdet as cfd '; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as cf'; $sql .= ' ON cfd.fk_commande = cf.rowid WHERE'; - if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) { + if (getDolGlobalInt("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER")) { $sql .= ' cf.fk_statut < 3'; - } elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) { + } elseif (getDolGlobalInt("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER")) { $sql .= ' cf.fk_statut < 6 AND cf.rowid NOT IN '.dispatchedOrders(); } else { $sql .= ' cf.fk_statut < 5';