Merge pull request #12750 from OPEN-DSI/v10-fix-product-virtual-stock-stats-sending

FIX add product qty in shipment already sent (fix for option STOCK_CALCULATE_ON_SHIPMENT_CLOSE)
This commit is contained in:
Laurent Destailleur 2020-01-03 20:56:59 +01:00 committed by GitHub
commit 0dafbd194f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 7 deletions

View File

@ -2636,12 +2636,13 @@ class Product extends CommonObject
/** /**
* Charge tableau des stats expedition client pour le produit/service * Charge tableau des stats expedition client pour le produit/service
* *
* @param int $socid Id societe pour filtrer sur une societe * @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 int $forVirtualStock Ignore rights filter for virtual stock calculation.
* @return array Tableau des stats * @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 // phpcs:enable
global $conf,$user; global $conf,$user;
@ -2671,6 +2672,7 @@ class Product extends CommonObject
if ($filtrestatut <> '') { if ($filtrestatut <> '') {
$sql.= " AND c.fk_statut in (".$filtrestatut.")"; $sql.= " AND c.fk_statut in (".$filtrestatut.")";
} }
if (!empty($filterShipmentStatus)) $sql.= " AND e.fk_statut IN (" . $filterShipmentStatus . ")";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result ) { if ($result ) {
@ -4464,7 +4466,14 @@ class Product extends CommonObject
} }
if (! empty($conf->expedition->enabled)) 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); if ($result < 0) dol_print_error($this->db, $this->error);
$stock_sending_client=$this->stats_expedition['qty']; $stock_sending_client=$this->stats_expedition['qty'];
} }

View File

@ -666,8 +666,15 @@ if ($id > 0 || $ref)
// Number of product from customer order already sent (partial shipping) // Number of product from customer order already sent (partial shipping)
if (!empty($conf->expedition->enabled)) { 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 .= '<br>'; else $found = 1; if ($found) $helpondiff .= '<br>'; 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']; $helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent") . ': ' . $object->stats_expedition['qty'];
} }