From 54df22c112916cf6ddee8acd97db9fd537c9cfaa Mon Sep 17 00:00:00 2001 From: alt-odoo Date: Mon, 21 Oct 2019 05:51:12 +0000 Subject: [PATCH] [FIX] survey: missing questions without section in survey Since commit https://github.com/odoo/odoo/commit/dba478332681dd21a39c4a183c002b1cf6e046d2, a survey can have questions with no section associated, which means 'page_ids' field will be empty. This prevents to display some questions of a survey, as we are still expecting a structure page/questions. To solve it, we first append questions with no sections, then all other questions. closes odoo/odoo#39113 X-original-commit: 149657cfd696e5065b55519927973fa785cc0e22 Signed-off-by: Alex Tuyls --- addons/survey/models/survey_survey.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/survey/models/survey_survey.py b/addons/survey/models/survey_survey.py index 25bfe3113e3..5647bb32c1e 100644 --- a/addons/survey/models/survey_survey.py +++ b/addons/survey/models/survey_survey.py @@ -298,6 +298,13 @@ class Survey(models.Model): questions = self.env['survey.question'] + # First append questions without page + for question in self.question_ids: + if not question.page_id: + questions |= question + + # Then, questions in sections + for page in self.page_ids: if self.questions_selection == 'all': questions |= page.question_ids @@ -307,9 +314,6 @@ class Survey(models.Model): else: questions |= page.question_ids - if not questions: - questions = self.question_ids - return questions def _has_attempts_left(self, partner, email, invite_token):