[FIX] survey: avoid traceback if you don't have finish the survey

If you have a survey of several pages, but don't valid all, you don't
have any survey_input_line for some question, so the [0] will crash.

Since the method wait only one input_line maximum, instead to force to
take the first one withtout take care if no reply, we just use the
browser record that will work in both case. If it is empty it will enter
in the 4th case, 'skipped' what is expected and was dead code before.

closes odoo/odoo#142500

X-original-commit: 02f49b726a40dc97f065ca40225411a208d65302
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
This commit is contained in:
Jeremy Kersten
2023-11-22 10:23:42 +00:00
committed by Aurélien Warnon
parent bf259290b7
commit d5c8abfd12
+1 -2
View File
@@ -497,8 +497,7 @@ class SurveyUserInput(models.Model):
else:
return 'skipped'
def _simple_choice_question_answer_result(self, user_input_lines, question_correct_suggested_answers, question_incorrect_scored_answers):
user_input_line = user_input_lines[0]
def _simple_choice_question_answer_result(self, user_input_line, question_correct_suggested_answers, question_incorrect_scored_answers):
user_answer = user_input_line.suggested_answer_id if not user_input_line.skipped else self.env['survey.question.answer']
if user_answer in question_correct_suggested_answers:
return 'correct'