diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index a440abd3471..8b45888d3ea 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -235,7 +235,10 @@ class FormProduct // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return full path to current warehouse in $tab (recursive function) - * + * Set Hidden conf MAIN_WAREHOUSE_LIST_DISPLAY_MODE at 0 || 1 || 2 to unlock display + * 0 : Default behavior, display parents of warehouse + * 1 : Display only current warehouse label only + * 2 : Display last parent warehouse label * @param array $tab warehouse data in $this->cache_warehouses line * @param string $final_label full label with all parents, separated by ' >> ' (completed on each call) * @return string full label with all parents, separated by ' >> ' @@ -247,11 +250,14 @@ class FormProduct $final_label = $tab['label']; } - if (empty($tab['parent_id'])) { + if (empty($tab['parent_id']) || getDolGlobalInt('MAIN_WAREHOUSE_LIST_DISPLAY_MODE') === 1) { return $final_label; } else { if (!empty($this->cache_warehouses[$tab['parent_id']])) { - $final_label = $this->cache_warehouses[$tab['parent_id']]['label'].' >> '.$final_label; + if (getDolGlobalInt('MAIN_WAREHOUSE_LIST_DISPLAY_MODE') !== 2 || (getDolGlobalInt('MAIN_WAREHOUSE_LIST_DISPLAY_MODE') === 2 && empty($this->cache_warehouses[$tab['parent_id']]['parent_id']))) { + $final_label = $this->cache_warehouses[$tab['parent_id']]['label'] . ' >> ' . $final_label; + } + return $this->get_parent_path($this->cache_warehouses[$tab['parent_id']], $final_label); } }