From 413bc625034d04c9845bf394319966ad47c9a7eb Mon Sep 17 00:00:00 2001 From: Richard Mathot <rim@openerp.com> Date: Fri, 8 Aug 2014 17:04:47 +0200 Subject: [PATCH] [FIX] survey: regressions introduced in forward-port fd4fd35e3239c771ab9d692f47f61770ae882965 --- addons/survey/survey.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index c4d7565c1f37..e36d0c596706 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -350,17 +350,14 @@ class survey_survey(osv.Model): #Calculate and return statistics for choice if question.type in ['simple_choice', 'multiple_choice']: - result_summary = [] - for label in question.labels_ids: - count = 0 - comments = [] - for input_line in question.user_input_line_ids: - if input_line.answer_type == 'suggestion' and input_line.value_suggested.id == label.id and (not current_filters or input_line.user_input_id.id in current_filters): - count = count + 1 - if input_line.answer_type == 'text' and (not current_filters or input_line.user_input_id.id in current_filters): - comments.append(input_line) - label_summary = {'text': label.value, 'count': count, 'answer_id': label.id, 'comments': comments} - result_summary = result_summary + [label_summary] + answers = {} + comments = [] + [answers.update({label.id: {'text': label.value, 'count': 0, 'answer_id': label.id}}) for label in question.labels_ids] + for input_line in question.user_input_line_ids: + if input_line.answer_type == 'suggestion' and answers.get(input_line.value_suggested.id) and (not(current_filters) or input_line.user_input_id.id in current_filters): + answers[input_line.value_suggested.id]['count'] += 1 + if input_line.answer_type == 'text' and (not(current_filters) or input_line.user_input_id.id in current_filters): + comments.append(input_line) result_summary = {'answers': answers.values(), 'comments': comments} #Calculate and return statistics for matrix -- GitLab