Skip to content

Commit

Permalink
[FIX] survey: avoid navigation crash
Browse files Browse the repository at this point in the history
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/<survey_id>/<token> without the /prev flag in the URL). This won't crash anymore.

This commit fixes odoo#2658 and odoo#2680.
  • Loading branch information
rim-odoo committed Jan 16, 2015
1 parent b117fcf commit f937690
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions addons/survey/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit f937690

Please sign in to comment.