[FIX] survey: fix the warning message while sharing the survey
Currently, while trying to share the survey with 'one page per section' layout, if the survey has only questions and no sections, a warning is raised that says 'You cannot send an invitation for a survey that has no questions'. It is misleading because in this case, what you do not have is atleast one section with question(s). This commit fixes the warning message for 'one page per section' type of survey and gives clear idea to the user about what is missing. TaskID-2611996 closes odoo/odoo#74694 X-original-commit: 381d18888d81f6797004c718fee5dbd9706b3122 Signed-off-by: awa-odoo <awa-odoo@users.noreply.github.com> Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -3084,6 +3084,18 @@ msgstr ""
|
||||
msgid "You cannot send an invitation for a survey that has no questions."
|
||||
msgstr ""
|
||||
|
||||
#. module: survey
|
||||
#: code:addons/survey/models/survey_survey.py:0
|
||||
#, python-format
|
||||
msgid "You cannot send an invitation for a \"One page per section\" survey if the survey has no sections."
|
||||
msgstr ""
|
||||
|
||||
#. module: survey
|
||||
#: code:addons/survey/models/survey_survey.py:0
|
||||
#, python-format
|
||||
msgid "You cannot send an invitation for a \"One page per section\" survey if the survey only contains empty sections."
|
||||
msgstr ""
|
||||
|
||||
#. module: survey
|
||||
#: code:addons/survey/models/survey_survey.py:0
|
||||
#, python-format
|
||||
|
||||
@@ -7,7 +7,7 @@ import uuid
|
||||
import werkzeug
|
||||
|
||||
from odoo import api, exceptions, fields, models, _
|
||||
from odoo.exceptions import AccessError
|
||||
from odoo.exceptions import AccessError, UserError
|
||||
from odoo.osv import expression
|
||||
from odoo.tools import is_html_empty
|
||||
|
||||
@@ -803,9 +803,16 @@ 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_section') or not self.question_ids:
|
||||
raise exceptions.UserError(_('You cannot send an invitation for a survey that has no questions.'))
|
||||
# Ensure that this survey has at least one question.
|
||||
if not self.question_ids:
|
||||
raise UserError(_('You cannot send an invitation for a survey that has no questions.'))
|
||||
|
||||
# Ensure that this survey has at least one section with question(s), if question layout is 'One page per section'.
|
||||
if self.questions_layout == 'page_per_section':
|
||||
if not self.page_ids:
|
||||
raise UserError(_('You cannot send an invitation for a "One page per section" survey if the survey has no sections.'))
|
||||
if not self.page_ids.mapped('question_ids'):
|
||||
raise UserError(_('You cannot send an invitation for a "One page per section" survey if the survey only contains empty sections.'))
|
||||
|
||||
if not self.active:
|
||||
raise exceptions.UserError(_("You cannot send invitations for closed surveys."))
|
||||
|
||||
Reference in New Issue
Block a user