From d5ea0bf26ba69e7fbb210b1b809291f9280e7e4c Mon Sep 17 00:00:00 2001 From: David Beguin Date: Wed, 3 Nov 2021 08:07:52 +0000 Subject: [PATCH] [IMP] survey: reload the survey where the user left it When going back, after this commit, the last displayed page is saved in order to reload the survey exactly where the user left it, instead of loading the survey at the latest question of the survey displayed to the user. Typically, if the user goes back and leave the survey on question 4, after reaching the question 7, instead of reloading the survey on question 7, the survey will be reloaded on question 4, where the user left the survey. Task-2225393 Part-of: odoo/odoo#79156 --- addons/survey/controllers/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/survey/controllers/main.py b/addons/survey/controllers/main.py index 3bd3d021e81..88c6f483426 100644 --- a/addons/survey/controllers/main.py +++ b/addons/survey/controllers/main.py @@ -484,16 +484,17 @@ class Survey(http.Controller): if answer_sudo.survey_time_limit_reached or survey_sudo.questions_layout == 'one_page': answer_sudo._mark_done() elif 'previous_page_id' in post: + # when going back, save the last displayed to reload the survey where the user left it. + answer_sudo.write({'last_displayed_page_id': post['previous_page_id']}) # Go back to specific page using the breadcrumb. Lines are saved and survey continues return self._prepare_question_html(survey_sudo, answer_sudo, **post) else: - vals = {'last_displayed_page_id': page_or_question_id} if not answer_sudo.is_session_answer: next_page = survey_sudo._get_next_page_or_question(answer_sudo, page_or_question_id) if not next_page: answer_sudo._mark_done() - answer_sudo.write(vals) + answer_sudo.write({'last_displayed_page_id': page_or_question_id}) return self._prepare_question_html(survey_sudo, answer_sudo)