From cd1fe29743ed7a37b365b93e0cf5b038d5943151 Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Fri, 27 Jun 2008 09:38:30 +0000 Subject: [PATCH] Add an optional parameter to push and pop methods. This allow generation of the right selection name when a listbox in a report mode is to be rendered with a prefix. As the renderer is not instanciated yet, it's not possible to just use it to retrieve the prefix. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22002 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/Report.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/product/ERP5Form/Report.py b/product/ERP5Form/Report.py index b694bf7938..17c336550d 100644 --- a/product/ERP5Form/Report.py +++ b/product/ERP5Form/Report.py @@ -266,7 +266,7 @@ class ReportSection: _no_parameter_ = [] security.declarePublic('pushReport') - def pushReport(self, context): + def pushReport(self, context, field_prefix=None): REQUEST = get_request() for k,v in self.param_dict.items(): self.saved_request[k] = REQUEST.form.get(k, self._no_parameter_) @@ -275,8 +275,10 @@ class ReportSection: portal_selections = context.portal_selections selection_list = [self.selection_name] if self.getFormId() and hasattr(context[self.getFormId()], 'listbox') : - selection_list += [ - context[self.getFormId()].listbox.get_value('selection_name') ] + selection_name = context[self.getFormId()].listbox.get_value('selection_name') + if field_prefix is not None: + selection_name = '%s_%s' % (field_prefix, selection_name) + selection_list += [selection_name] # save report's selection and orignal form's selection, #as ListBox will overwrite it for selection_name in selection_list : @@ -305,11 +307,12 @@ class ReportSection: REQUEST, self.listbox_display_mode, selection_name=selection_name) if self.selection_params is not None: - self.saved_selections[selection_name]['params'] = \ - portal_selections.getSelectionParams( + params = portal_selections.getSelectionParams( selection_name, REQUEST=REQUEST) + self.saved_selections[selection_name]['params'] = params.copy() + params.update(self.selection_params) portal_selections.setSelectionParamsFor(selection_name, - self.selection_params, REQUEST=REQUEST) + params, REQUEST=REQUEST) if self.selection_columns is not None: self.saved_selections[selection_name]['columns'] = \ portal_selections.getSelectionColumns(selection_name, @@ -327,7 +330,7 @@ class ReportSection: REQUEST.form = {} security.declarePublic('popReport') - def popReport(self, context): + def popReport(self, context, field_prefix=None): REQUEST = get_request() for k,v in self.param_dict.items(): if self.saved_request[k] is self._no_parameter_: @@ -338,8 +341,12 @@ class ReportSection: portal_selections = context.portal_selections selection_list = [] if self.getFormId() and hasattr(context[self.getFormId()], 'listbox') : - selection_list += [ - context[self.getFormId()].listbox.get_value('selection_name') ] + selection_name = context[self.getFormId()].listbox.get_value('selection_name') + if field_prefix is not None: + # Return before cleanup, because there is no interest in cleaning up + # what won't be shared. + return + selection_list += [selection_name] selection_list += [self.selection_name] # restore report then form selection for selection_name in selection_list: @@ -381,4 +388,4 @@ class ReportSection: REQUEST.form = self.saved_request_form InitializeClass(ReportSection) -allow_class(ReportSection) \ No newline at end of file +allow_class(ReportSection) -- 2.30.9