Bug
A previous commit b1ec81ed fixed an issue relating to wrong progression
percentages when a survey was set as "one page per question" and
"random selection".
In doing so, it inadvertently added an issue in the following simplified case:
1. Create a new survey, and add 2 questions
2. Set layout (`question_layout`) to "one page per question" (`page_per_question`)
3. Set selection (`question_selection`) to "all questions" (`all`)
4. Now share the survey with a participant (send out the email)
5. As the participant, start the survey and answer question one
6. In the backend, go and modify the survey template by adding a new
question after question 2. Save modification.
7. Now, in the ongoing survey, answer question 2 and try to move on to
the next question.
This will create an error traceback. Example
'''
'page_number': page_ids.index(survey_data['question'].id)
ValueError: 108 is not in list
'''
The error arises because the added question will have an id that is not
in the `survey.user_input.predefined_question_ids` field. This list gets
initialized when the `survey.user_input` gets created and reflects all
the question ids of the original survey template (or the random ids in
case of a random selection).
So in other terms the set of questions given to a participant, starting
in `survey_survey._get_pages_or_questions` is not aligned with those used
for the references in the progression template
Proposed fix:
We add an extra check for `survey_sudo.questions_selection == 'random'`
to decide if we use `survey.user_input.predefined_question_ids` or
`survey.survey.question_ids` information to calculate the progession.
opw-3516304
closesodoo/odoo#141171
X-original-commit: 643fceff43770483f11e95bd57fae60e611f83d4
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Signed-off-by: Joel Rodrigues Vitória (jorv) <jorv@odoo.com>