From b0edd464948af16d11adbd5ed311bf15cc55b958 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 23 Dec 2019 15:07:26 +0100 Subject: [PATCH 1/2] FIX add product qty in shipment already sent --- htdocs/product/class/product.class.php | 21 +++++++++++++++------ htdocs/product/stock/product.php | 9 ++++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d00cba86e6a..c61d778a9f9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2633,12 +2633,13 @@ class Product extends CommonObject /** * Charge tableau des stats expedition client pour le produit/service * - * @param int $socid Id societe pour filtrer sur une societe - * @param string $filtrestatut Id statut pour filtrer sur un statut - * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. - * @return array Tableau des stats + * @param int $socid Id societe pour filtrer sur une societe + * @param string $filtrestatut Id statut pour filtrer sur un statut + * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. + * @param string $filterShipmentStatus [=''] Ids shipment status separated by comma + * @return int <0 if KO, >0 if OK (Tableau des stats) */ - public function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0) + public function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0, $filterShipmentStatus = '') { // phpcs:enable global $conf,$user; @@ -2668,6 +2669,7 @@ class Product extends CommonObject if ($filtrestatut <> '') { $sql.= " AND c.fk_statut in (".$filtrestatut.")"; } + if (!empty($filterShipmentStatus)) $sql.= " AND e.fk_statut IN (" . $filterShipmentStatus . ")"; $result = $this->db->query($sql); if ($result ) { @@ -4461,7 +4463,14 @@ class Product extends CommonObject } if (! empty($conf->expedition->enabled)) { - $result=$this->load_stats_sending(0, '1,2', 1); + require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + $filterShipmentStatus = ''; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { + $filterShipmentStatus = Expedition::STATUS_VALIDATED . ',' . Expedition::STATUS_CLOSED; + } elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + $filterShipmentStatus = Expedition::STATUS_CLOSED; + } + $result = $this->load_stats_sending(0, '1,2', 1, $filterShipmentStatus); if ($result < 0) dol_print_error($this->db, $this->error); $stock_sending_client=$this->stats_expedition['qty']; } diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 944b3ce96cd..89e60ed07ed 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -666,8 +666,15 @@ if ($id > 0 || $ref) // Number of product from customer order already sent (partial shipping) if (!empty($conf->expedition->enabled)) { + require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + $filterShipmentStatus = ''; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { + $filterShipmentStatus = Expedition::STATUS_VALIDATED . ',' . Expedition::STATUS_CLOSED; + } elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + $filterShipmentStatus = Expedition::STATUS_CLOSED; + } if ($found) $helpondiff .= '
'; else $found = 1; - $result = $object->load_stats_sending(0, '2', 1); + $result = $object->load_stats_sending(0, '2', 1, $filterShipmentStatus); $helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent") . ': ' . $object->stats_expedition['qty']; } From 37f93077328b8567674d57f19cb35005bd7f78fd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Jan 2020 20:53:49 +0100 Subject: [PATCH 2/2] Update product.class.php --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c61d778a9f9..4a8390d80cd 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2634,7 +2634,7 @@ class Product extends CommonObject * Charge tableau des stats expedition client pour le produit/service * * @param int $socid Id societe pour filtrer sur une societe - * @param string $filtrestatut Id statut pour filtrer sur un statut + * @param string $filtrestatut [=''] Ids order status separated by comma * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. * @param string $filterShipmentStatus [=''] Ids shipment status separated by comma * @return int <0 if KO, >0 if OK (Tableau des stats)