diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php
index 8dc86f394a3..f033e91ceff 100644
--- a/htdocs/product/class/html.formproduct.class.php
+++ b/htdocs/product/class/html.formproduct.class.php
@@ -245,27 +245,6 @@ class FormProduct
if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) $filterstatus = '';
if (!empty($fk_product)) $this->cache_warehouses = array();
- $parameters = array(
- 'selected' => & $selected,
- 'htmlname' =>& $htmlname,
- 'filterstatus' =>& $filterstatus,
- 'empty' =>& $empty,
- 'disabled ' =>& $disabled,
- 'fk_product' =>& $fk_product,
- 'empty_label' =>& $empty_label,
- 'showstock' =>& $showstock,
- 'forcecombo' =>& $forcecombo,
- 'events' =>& $events,
- 'morecss' =>& $morecss,
- 'exclude' =>& $exclude,
- 'showfullpath' =>& $showfullpath,
- 'stockMin' =>& $stockMin,
- 'orderBy' =>& $orderBy
- );
-
- $reshook = $hookmanager->executeHooks('selectWarehouses', $parameters, $this);
- if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-
$this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude, $stockMin, $orderBy);
$nbofwarehouses=count($this->cache_warehouses);
@@ -304,6 +283,27 @@ class FormProduct
$out.='';
if ($disabled) $out.='';
+ $parameters = array(
+ 'selected' => $selected,
+ 'htmlname' => $htmlname,
+ 'filterstatus' => $filterstatus,
+ 'empty' => $empty,
+ 'disabled ' => $disabled,
+ 'fk_product' => $fk_product,
+ 'empty_label' => $empty_label,
+ 'showstock' => $showstock,
+ 'forcecombo' => $forcecombo,
+ 'events' => $events,
+ 'morecss' => $morecss,
+ 'exclude' => $exclude,
+ 'showfullpath' => $showfullpath,
+ 'stockMin' => $stockMin,
+ 'orderBy' => $orderBy
+ );
+
+ $reshook = $hookmanager->executeHooks('selectWarehouses', $parameters, $this);
+ if ($reshook > 0) $out = $hookmanager->resPrint;
+
return $out;
}