From f9376905cc53b36ca888ff384317ce6b8d570b0f Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Fri, 16 Jan 2015 17:10:20 +0100 Subject: [PATCH] [FIX] survey: avoid navigation crash If a survey has "allow users to go back" option enabled, users can go back to previous pages and change their answers before submitting the whole survey. This commit fixes the very special case, when the user reaches the last page of the survey, then click on "Previous" button, then reopen the survey from the invitation URL (/survey/fill// without the /prev flag in the URL). This won't crash anymore. This commit fixes #2658 and #2680. --- addons/survey/controllers/main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/survey/controllers/main.py b/addons/survey/controllers/main.py index 5e61e46cfa8c3..511d70896c35a 100644 --- a/addons/survey/controllers/main.py +++ b/addons/survey/controllers/main.py @@ -166,6 +166,11 @@ def fill_survey(self, survey, token, prev=None, **post): elif user_input.state == 'skip': flag = (True if prev and prev == 'prev' else False) page, page_nr, last = survey_obj.next_page(cr, uid, user_input, user_input.last_displayed_page_id.id, go_back=flag, context=context) + + #special case if you click "previous" from the last page, then leave the survey, then reopen it from the URL, avoid crash + if not page: + page, page_nr, last = survey_obj.next_page(cr, uid, user_input, user_input.last_displayed_page_id.id, go_back=True, context=context) + data = {'survey': survey, 'page': page, 'page_nr': page_nr, 'token': user_input.token} if last: data.update({'last': True})