[FIX] survey: allow creating survey with no sections

Task#1958723

This commit fixes the survey form to allow creating, testing and sharing
surveys that don't have sections as long as they don't use the "page_per_section"
layout.

closes odoo/odoo#32159

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Aurélien Warnon
2019-04-10 15:03:10 +00:00
parent 61495126ae
commit 2268e747c9
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -72,7 +72,7 @@ class Survey(http.Controller):
if (survey_sudo.is_closed or not survey_sudo.active) and (not answer_sudo or not answer_sudo.test_entry):
return 'survey_closed'
if not survey_sudo.page_ids and survey_sudo.questions_layout != 'page_per_question':
if (not survey_sudo.page_ids and survey_sudo.questions_layout == 'page_per_section') or not survey_sudo.question_ids:
return 'survey_void'
if answer_sudo and answer_sudo.state == 'done':
+4 -2
View File
@@ -278,7 +278,9 @@ class Survey(models.Model):
"""
survey = user_input.survey_id
if survey.questions_layout == 'page_per_question' and survey.questions_selection == 'random':
if survey.questions_layout == 'one_page':
return (None, False)
elif survey.questions_layout == 'page_per_question' and survey.questions_selection == 'random':
pages_or_questions = list(enumerate(
user_input.question_ids
))
@@ -451,7 +453,7 @@ class Survey(models.Model):
def action_send_survey(self):
""" Open a window to compose an email, pre-filled with the survey message """
# Ensure that this survey has at least one page with at least one question.
if (not self.page_ids and self.questions_layout != 'page_per_question') or not self.question_ids:
if (not self.page_ids and self.questions_layout == 'page_per_section') or not self.question_ids:
raise UserError(_('You cannot send an invitation for a survey that has no questions.'))
if self.stage_id.closed: