diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php
index d8979d5e1c3..fe4171de72e 100644
--- a/htdocs/cashdesk/index.php
+++ b/htdocs/cashdesk/index.php
@@ -106,7 +106,7 @@ if (! empty($conf->stock->enabled))
print '
';
$disabled=0;
if (! empty($conf->global->CASHDESK_ID_WAREHOUSE)) $disabled=1; // If a particular stock is defined, we disable choice
- print $formproduct->selectWarehouses(GETPOST('warehouseid')?GETPOST('warehouseid'):$conf->global->CASHDESK_ID_WAREHOUSE,'warehouseid','',!$disabled,$disabled);
+ print $formproduct->selectWarehouses((GETPOST('warehouseid')?GETPOST('warehouseid'):(empty($conf->global->CASHDESK_ID_WAREHOUSE)?'ifone':$conf->global->CASHDESK_ID_WAREHOUSE)),'warehouseid','',!$disabled,$disabled);
//print '';
print '
';
print "\n";
diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php
index 45b0a129808..40658c97fb8 100644
--- a/htdocs/product/class/html.formproduct.class.php
+++ b/htdocs/product/class/html.formproduct.class.php
@@ -101,9 +101,9 @@ class FormProduct
}
/**
- * Return list of possible payments modes
+ * Return list of warehouses
*
- * @param int $selected Id du mode de paiement pre-selectionne
+ * @param int $selected Id of preselected warehouse ('' for no value, 'ifone'=select value if one value otherwise no value)
* @param string $htmlname Name of html select html
* @param string $filtertype For filter
* @param int $empty 1=Can be empty, 0 if not
@@ -119,23 +119,22 @@ class FormProduct
dol_syslog(get_class($this)."::selectWarehouses $selected, $htmlname, $filtertype, $empty, $disabled, $fk_product",LOG_DEBUG);
$this->loadWarehouses($fk_product);
-
+ $nbofwarehouses=count($this->cache_warehouses);
+
$out='';
- if ($disabled) $out.='';
+ if ($disabled) $out.='';
- //count($this->cache_warehouses);
return $out;
}