diff --git a/addons/survey/controllers/main.py b/addons/survey/controllers/main.py index ae410d6d70e..bd08fecf6d1 100644 --- a/addons/survey/controllers/main.py +++ b/addons/survey/controllers/main.py @@ -298,7 +298,11 @@ class WebsiteSurvey(http.Controller): type='http', auth='user', multilang=True, website=True) def survey_reporting(self, survey, token=None, **post): '''Display survey Results & Statistics for given survey.''' - result_template, current_filters, filter_display_data, filter_finish = 'survey.result', [], [], False + result_template ='survey.result' + current_filters = [] + filter_display_data = [] + filter_finish = False + survey_obj = request.registry['survey.survey'] if not survey.user_input_ids or not [input_id.id for input_id in survey.user_input_ids if input_id.state != 'new']: result_template = 'survey.no_result' @@ -307,7 +311,7 @@ class WebsiteSurvey(http.Controller): filter_finish = True if post or filter_finish: filter_data = self.get_filter_data(post) - current_filters = survey_obj.filter_input_ids(request.cr, request.uid, filter_data, filter_finish, context=request.context) + current_filters = survey_obj.filter_input_ids(request.cr, request.uid, survey, filter_data, filter_finish, context=request.context) filter_display_data = survey_obj.get_filter_display_data(request.cr, request.uid, filter_data, context=request.context) return request.website.render(result_template, {'survey': survey, diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 813b2423671..e5e1149a7d7 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -282,7 +282,7 @@ class survey_survey(osv.Model): else: return (pages[current_page_index + 1][1], current_page_index + 1, False) - def filter_input_ids(self, cr, uid, filters, finished=False, context=None): + def filter_input_ids(self, cr, uid, survey, filters, finished=False, context=None): '''If user applies any filters, then this function returns list of filtered user_input_id and label's strings for display data in web. :param filters: list of dictionary (having: row_id, ansewr_id) @@ -311,7 +311,7 @@ class survey_survey(osv.Model): if finished: user_input = self.pool.get('survey.user_input') if not filtered_input_ids: - current_filters = user_input.search(cr, uid, [], context=context) + current_filters = user_input.search(cr, uid, [('survey_id', '=', survey.id)], context=context) user_input_objs = user_input.browse(cr, uid, current_filters, context=context) else: user_input_objs = user_input.browse(cr, uid, filtered_input_ids, context=context)