From ad5f8e2eff49b5ac9cbd9e353a21c5de4b5fc88e Mon Sep 17 00:00:00 2001 From: alt-odoo Date: Mon, 23 Aug 2021 20:30:15 +0000 Subject: [PATCH] [FIX] survey: No crash when getting stats of answers of a survey If for any reason the initial linked question of one possible answer was changed and if one existing survey has already been answered using that possibility, we currently got an Internal Server Error while we should simply just ignore these answers when getting the statistics of that survey. closes odoo/odoo#75758 X-original-commit: 87096c284872f9aa99f5ae9096cee92663c4933e Signed-off-by: Alex Tuyls --- addons/survey/models/survey_question.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/survey/models/survey_question.py b/addons/survey/models/survey_question.py index e1d9d2d9a20..ff3204f7d45 100644 --- a/addons/survey/models/survey_question.py +++ b/addons/survey/models/survey_question.py @@ -438,7 +438,8 @@ class SurveyQuestion(models.Model): count_data = dict.fromkeys(suggested_answers, 0) for line in user_input_lines: - if line.suggested_answer_id or (line.value_char_box and self.comment_count_as_answer): + if line.suggested_answer_id in count_data\ + or (line.value_char_box and self.comment_count_as_answer): count_data[line.suggested_answer_id] += 1 table_data = [{