Commit 76112cc2 authored by Ivan Tyagov's avatar Ivan Tyagov

Do not fail if module has not a selection.

If selection is not define generate report on current context.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17239 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent be1b3060
......@@ -75,22 +75,35 @@ form = context\n
request = context.REQUEST\n
report_section_list = []\n
portal = context.getPortalObject()\n
selection_name=request.form[\'selection_name\']\n
selection_name=request.form.get(\'selection_name\', None)\n
translate = lambda msg: Message(\'ui\', msg)\n
\n
#get all documents in the selection\n
for doc in portal.portal_selections.callSelectionFor(selection_name, context=form):\n
def getReportSectionListForObject(doc):\n
""" Get all possible report section for object. """\n
report_section_list = []\n
doc = doc.getObject()\n
title = doc.getTitle()\n
title = translate(title)\n
report_section_list.append(ReportSection(level=1, title=title, form_id=None))\n
\n
report_section_list.append(ReportSection(level = 1, \n
title = title, \n
form_id = None))\n
for action in portal.portal_actions.listFilteredActionsFor(doc)[\'object_view\']:\n
form_id = action[\'url\'].split(\'/\')[-1].split(\'?\')[0]\n
action_title= action[\'title\'] \n
\n
action_title = action[\'title\'] \n
if action_title != \'History\' and action_title != \'Metadata\':\n
report_section_list.append(ReportSection(path=doc.getPath(), form_id=form_id, level=2, title=\'%s-%s\' % (title, translate(action_title))))\n
report_section_list.append(ReportSection(path = doc.getPath(), \n
form_id = form_id, \n
level = 2, \n
title = \'%s-%s\' % (title, translate(action_title))))\n
return report_section_list\n
\n
if selection_name is not None:\n
# get all documents in the selection\n
for doc in portal.portal_selections.callSelectionFor(selection_name, context=form):\n
report_section_list.extend(getReportSectionListForObject(doc))\n
else:\n
# get only current (context) document \n
report_section_list.extend(getReportSectionListForObject(context))\n
\n
return report_section_list\n
</string> </value>
......@@ -145,16 +158,12 @@ return report_section_list\n
<string>request</string>
<string>report_section_list</string>
<string>portal</string>
<string>_getitem_</string>
<string>None</string>
<string>selection_name</string>
<string>translate</string>
<string>getReportSectionListForObject</string>
<string>_getiter_</string>
<string>doc</string>
<string>title</string>
<string>None</string>
<string>action</string>
<string>form_id</string>
<string>action_title</string>
</tuple>
</value>
</item>
......
87
\ No newline at end of file
88
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment