diff --git a/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/Listbox_getReportTreeStructure.xml b/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/Listbox_getReportTreeStructure.xml
index c273987fb403913a7e8878dff2f94d48a340fe26..3de4e69d63b3d4b15eed0a608ecd6568c7e76bc4 100644
--- a/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/Listbox_getReportTreeStructure.xml
+++ b/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/Listbox_getReportTreeStructure.xml
@@ -56,7 +56,7 @@ structure = {}\n
 structure[\'line\'] = None\n
 structure[\'line_list\'] = []\n
 \n
-if not (is_report_tree_mode or is_domain_tree_mode):\n
+if not ((is_report_tree_mode or is_domain_tree_mode) and max_section_depth):\n
   # When this is not a report tree, return the "plain structure"\n
   structure[\'line\'] = None\n
   structure[\'line_list\'] = [dict(line=x, line_list=[]) for x in listbox_line_list]\n
@@ -83,6 +83,8 @@ def order_line_list(line_list, current_structure, depth=0, index=0, last_dict=No
     else:\n
       return index\n
   if index < len(line_list):\n
+    # FIXME: this way of recursing is not appropriate, as we reach very easily the maximum\n
+    # recursion depth from python.\n
     index = order_line_list(line_list, current_structure, depth=depth, index=index, last_dict=last_dict)\n
   return index\n
 \n
@@ -95,7 +97,7 @@ return structure\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>listbox_line_list=None, is_report_tree_mode=False, is_domain_tree_mode=False</string> </value>
+            <value> <string>listbox_line_list=None, is_report_tree_mode=False, is_domain_tree_mode=False, max_section_depth=0</string> </value>
         </item>
         <item>
             <key> <string>id</string> </key>
diff --git a/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/listbox_ods_macro.xml b/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/listbox_ods_macro.xml
index f34cf060d1c8d809f2b9ab523cb7ad40f1c67528..5a347a9f3956338d50de20715da863049306aa92 100644
--- a/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/listbox_ods_macro.xml
+++ b/bt5/erp5_ods_style/SkinTemplateItem/portal_skins/erp5_ods_style/listbox_ods_macro.xml
@@ -57,9 +57,9 @@
                selection python: here.portal_selections.getSelectionFor(selection_name, REQUEST=request);\n
                is_report_tree_mode selection/report_tree_mode | python: 0;\n
                is_domain_tree_mode selection/domain_tree_mode | python: 0;\n
-               listbox_line_structure python: here.Listbox_getReportTreeStructure(listbox_line_list=listboxline_list[1:], is_report_tree_mode=is_report_tree_mode, is_domain_tree_mode=is_domain_tree_mode);\n
-               listboxline python:listboxline_list[0];\n
                max_section_depth python: max([x.getSectionDepth() for x in listboxline_list]) + int(is_report_tree_mode);\n
+               listbox_line_structure python: here.Listbox_getReportTreeStructure(listbox_line_list=listboxline_list[1:], is_report_tree_mode=is_report_tree_mode, is_domain_tree_mode=is_domain_tree_mode, max_section_depth=max_section_depth);\n
+               listboxline python:listboxline_list[0];\n
                " i18n:domain="ui">\n
 \n
             <tal:block tal:condition="listboxline/isTitleLine">\n
diff --git a/bt5/erp5_ods_style/bt/revision b/bt5/erp5_ods_style/bt/revision
index f123c4f4b597ed834ae3c05dd9d4c96cf014f2bb..1c5fd036efa9eace125dcd3660845c008a836768 100644
--- a/bt5/erp5_ods_style/bt/revision
+++ b/bt5/erp5_ods_style/bt/revision
@@ -1 +1 @@
-251
\ No newline at end of file
+252
\ No newline at end of file