From 826a25c7d1896414721f4ff8d1ce57795ad5e030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Warnon?= Date: Fri, 20 Mar 2020 10:58:01 +0000 Subject: [PATCH] [FIX] survey: fix back button behavior This commit fixes 2 small problems when the user goes back on the survey form: - The back button should not be shown on "page_per_question" layout if we are on the first page of the survey. Pages can be displayed on "page_per_question" layout if they have a description since #44271 - Can't go back on "page_per_section" layout if you are on the second page of the survey, introduced by 0675d68afb7afe69e5e9d62a172c273a6d0b83e8 LINKS PR #48442 Task 2208574 --- addons/survey/models/survey_survey.py | 2 +- addons/survey/views/survey_templates.xml | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/survey/models/survey_survey.py b/addons/survey/models/survey_survey.py index da8e1670fad..94d3a5bece6 100644 --- a/addons/survey/models/survey_survey.py +++ b/addons/survey/models/survey_survey.py @@ -481,7 +481,7 @@ class Survey(models.Model): current_page_index = pages_or_questions.ids.index(next(p.id for p in pages_or_questions if p.id == page_or_question_id)) # Get previous and we are on first page OR Get Next and we are on last page - if (go_back and current_page_index == 0) or current_page_index == len(pages_or_questions) - 1: + if (go_back and current_page_index == 0) or (not go_back and current_page_index == len(pages_or_questions) - 1): return Question # Conditional Questions Management diff --git a/addons/survey/views/survey_templates.xml b/addons/survey/views/survey_templates.xml index 4cc54cca006..b8addaaab7f 100644 --- a/addons/survey/views/survey_templates.xml +++ b/addons/survey/views/survey_templates.xml @@ -202,8 +202,15 @@
- + +