FIX: Replenish: SQL error when no warehouse has been created + Warning when there are no warehouses

This commit is contained in:
Administrator 2021-10-28 12:57:10 +02:00
parent 2436f0967b
commit 44eedb8c6e
2 changed files with 11 additions and 3 deletions

View File

@ -255,4 +255,5 @@ MakeMovementsAndClose=Generate movements and close
AutofillWithExpected=Fill real quantity with expected quantity
ShowAllBatchByDefault=By default, show batch details on product "stock" tab
CollapseBatchDetailHelp=You can set batch detail default display in stocks module configuration
FieldCannotBeNegative=Field "%s" cannot be negative
FieldCannotBeNegative=Field "%s" cannot be negative
ErrorAtLeastOneWarehouseNeededForReplenish= Attention: You need to create at least one warehouse to use the replenish feature.

View File

@ -358,12 +358,14 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N
$sql .= $hookmanager->resPrint;
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product AND s.fk_entrepot IN ('.$db->sanitize($listofqualifiedwarehousesid).')';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product';
$list_warehouse = empty($listofqualifiedwarehousesid) ? '0' :$db->sanitize($listofqualifiedwarehousesid);
$sql .= ' AND s.fk_entrepot IN ('.$list_warehouse .')';
//$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot AS ent ON s.fk_entrepot = ent.rowid AND ent.entity IN('.getEntity('stock').')';
if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.((int) $fk_entrepot).')';
}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook
@ -577,6 +579,11 @@ print load_fiche_titre($langs->trans('Replenishment'), '', 'stock');
print dol_get_fiche_head($head, 'replenish', '', -1, '');
print '<span class="opacitymedium">'.$langs->trans("ReplenishmentStatusDesc").'</span>'."\n";
$link = '<a title=' .$langs->trans("MenuNewWarehouse"). ' href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create">'.$langs->trans("MenuNewWarehouse").'</a>';
print info_admin($langs->trans("ErrorAtLeastOneWarehouseNeededForReplenish") .' '. $link, 0, 0, 'info', 'clearboth');
if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) {
print '<span class="opacitymedium">'.$langs->trans("ReplenishmentStatusDescPerWarehouse").'</span>'."\n";
}