Merge pull request #19235 from noec764/14.0_FIX_Error_in_stock_module

FIX: Replenish: SQL error when no warehouse has been created
This commit is contained in:
Laurent Destailleur 2021-10-31 14:22:31 +01:00 committed by GitHub
commit ffcc6b6d69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -255,4 +255,4 @@ 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

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' : $listofqualifiedwarehousesid);
$sql .= ' AND s.fk_entrepot IN ('.$db->sanitize($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,9 @@ 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>';
if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) {
print '<span class="opacitymedium">'.$langs->trans("ReplenishmentStatusDescPerWarehouse").'</span>'."\n";
}