Commit 96e20564 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Add to reports the possiblity to invoke a method on the report context in...

Add to reports the possiblity to invoke a method on the report context in order to find the object on which the form should be applied to. This is used by the new documentation system to build DocumentationHelper instances (which do not exist within the ZODB) for each URI of each report section.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17611 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9709052f
...@@ -189,14 +189,21 @@ class ReportSection: ...@@ -189,14 +189,21 @@ class ReportSection:
meta_type = "ReportSection" meta_type = "ReportSection"
security = ClassSecurityInfo() security = ClassSecurityInfo()
param_dict = {} def __init__(self, path='',
form_id='',
def __init__(self, path='', form_id='', method_id=None,
title=None, translated_title=None, level=1, title=None,
selection_name=None, selection_params=None, translated_title=None,
listbox_display_mode=None, selection_columns=None, level=1,
param_list=None,
param_dict=None,
selection_name=None,
selection_params=None,
listbox_display_mode=None,
selection_columns=None,
selection_sort_order=None, selection_sort_order=None,
selection_report_path=None, selection_report_list=None): selection_report_path=None,
selection_report_list=None):
""" """
Initialize the line and set the default values Initialize the line and set the default values
Selected columns must be defined in parameter of listbox.render... Selected columns must be defined in parameter of listbox.render...
...@@ -223,6 +230,9 @@ class ReportSection: ...@@ -223,6 +230,9 @@ class ReportSection:
self.selection_report_path = selection_report_path self.selection_report_path = selection_report_path
self.selection_report_list = selection_report_list self.selection_report_list = selection_report_list
self.saved_request_form = {} self.saved_request_form = {}
self.param_dict = param_dict or {}
self.param_list = param_list or []
self.method_id = method_id
security.declarePublic('getTitle') security.declarePublic('getTitle')
def getTitle(self): def getTitle(self):
...@@ -243,7 +253,11 @@ class ReportSection: ...@@ -243,7 +253,11 @@ class ReportSection:
security.declarePublic('getObject') security.declarePublic('getObject')
def getObject(self, context): def getObject(self, context):
return context.getPortalObject().restrictedTraverse(self.path) object = context.getPortalObject().restrictedTraverse(self.path)
if self.method_id is not None:
object = getattr(object, self.method_id)(*self.param_list, **self.param_dict)
return object
security.declarePublic('getFormId') security.declarePublic('getFormId')
def getFormId(self): def getFormId(self):
...@@ -260,9 +274,9 @@ class ReportSection: ...@@ -260,9 +274,9 @@ class ReportSection:
portal_selections = context.portal_selections portal_selections = context.portal_selections
selection_list = [self.selection_name] selection_list = [self.selection_name]
if self.form_id and hasattr(context[self.form_id], 'listbox') : if self.getFormId() and hasattr(context[self.getFormId()], 'listbox') :
selection_list += [ selection_list += [
context[self.form_id].listbox.get_value('selection_name') ] context[self.getFormId()].listbox.get_value('selection_name') ]
# save report's selection and orignal form's selection, # save report's selection and orignal form's selection,
#as ListBox will overwrite it #as ListBox will overwrite it
for selection_name in selection_list : for selection_name in selection_list :
...@@ -323,9 +337,9 @@ class ReportSection: ...@@ -323,9 +337,9 @@ class ReportSection:
portal_selections = context.portal_selections portal_selections = context.portal_selections
selection_list = [] selection_list = []
if self.form_id and hasattr(context[self.form_id], 'listbox') : if self.getFormId() and hasattr(context[self.getFormId()], 'listbox') :
selection_list += [ selection_list += [
context[self.form_id].listbox.get_value('selection_name') ] context[self.getFormId()].listbox.get_value('selection_name') ]
selection_list += [self.selection_name] selection_list += [self.selection_name]
# restore report then form selection # restore report then form selection
for selection_name in selection_list: for selection_name in selection_list:
...@@ -368,4 +382,3 @@ class ReportSection: ...@@ -368,4 +382,3 @@ class ReportSection:
InitializeClass(ReportSection) InitializeClass(ReportSection)
allow_class(ReportSection) allow_class(ReportSection)
\ 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