From 483e902947e265bdb14b0df5b76c032a6f116e54 Mon Sep 17 00:00:00 2001
From: Kevin Deldycke <kevin@nexedi.com>
Date: Wed, 24 Aug 2005 15:22:36 +0000
Subject: [PATCH] This is the second attemp by Moussa to correct the bug #56.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3646 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/ListBox.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py
index 5f247190e8..68aeec3277 100755
--- a/product/ERP5Form/ListBox.py
+++ b/product/ERP5Form/ListBox.py
@@ -72,10 +72,6 @@ def makeTreeBody(form, root_dict, domain_path, depth, total_depth, unfolded_list
   if total_depth is None:
     total_depth = max(1, len(unfolded_list))
 
-  # This two lines must correct the bug #56
-  if domain_path == ('portal_categories',):
-    return ''
-
   if type(domain_path) is type('a'): domain_path = domain_path.split('/')
 
   portal_categories = getattr(form, 'portal_categories', None)
@@ -170,6 +166,7 @@ def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfol
             root = root_dict[base_category] = root_dict[None] = portal_categories[base_category]
             report_path = report_path[1:]
       if root is None and portal_domains is not None:
+
         if base_category in portal_domains.objectIds():
           root = root_dict[base_category] = root_dict[None] = portal_domains[base_category]
           report_path = report_path[1:]
@@ -914,7 +911,7 @@ class ListBoxWidget(Widget.Widget):
             pass
           else:
             default_selection_report_path = report_root_list[0][0]
-          selection_report_path = selection.getReportPath(default = (default_selection_report_path,))
+          selection_report_path = selection.getReportPath(default = default_selection_report_path)
           if report_depth is not None:
             selection_report_current = ()
           else:
@@ -1891,20 +1888,25 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
         #Create DomainTree Selector and DomainTree box
         if domain_tree:
           select_tree_options = ''
+          default_selected = ''
           for c in domain_root_list:
             if c[0] == selection_domain_path:
               select_tree_options += """<option selected value="%s">%s</option>\n""" % (c[0], c[1])
             else:
               select_tree_options += """<option value="%s">%s</option>\n""" % (c[0], c[1])
+              if default_selected == '':
+                default_selected = c[0] #the first is selected
           select_tree_header = """<select name="domain_root_url"
 onChange="submitAction(this.form,'%s/portal_selections/setDomainRoot')">
         %s</select>""" % (here.getUrl(),select_tree_options)
 
           try:
-            select_tree_body = makeTreeBody(form, None, selection_domain_path,
-                 0, None, selection_domain_current, form.id, selection_name)
+              if selection_domain_path == ('portal_categories',):
+                selection_domain_path = default_selected
+              select_tree_body = makeTreeBody(form, None, selection_domain_path,
+                      0, None, selection_domain_current, form.id, selection_name)
           except KeyError:
-            select_tree_body = ''
+              select_tree_body = ''
 
           select_tree_html = """<!-- Select Tree -->
 %s
@@ -1948,6 +1950,7 @@ class ListBoxValidator(Validator.Validator):
         portal_url = getToolByName(here, 'portal_url')
         portal = portal_url.getPortalObject()
 
+
         result = {}
         error_result = {}
         listbox_uids = REQUEST.get('%s_uid' % field.id, [])
-- 
2.30.9