From 2faefd4757cb48269132aae9d460f9581e6020b1 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Dufays Date: Fri, 28 Jan 2022 15:18:58 +0000 Subject: [PATCH] [IMP] website_event[_questions]: allow setting event questions as mandatory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Purpose: Allow users to make sure they will get an answer to the questions they ask attendees while they register. e.g.: - You organize activities for kids and want to make sure you have a second phone number available in case of emergencies - You organize B2B events and need to know in which industry your attendees work - You use the Event/CRM bridge and plan to filter attendees based on those answers ... Specifications: In the question form view, a boolean "Mandatory Answer" has been added. In the list view, that field has been added as column. In the registration form: - "*", next to each mandatory question has been added - "*" has been added next to name and email which were already mandatory - the mandatory question have been actually made mandatory by preventing user to submit empty answer Remark: once_per_order was missing in the list view of the event template questions. We have added it as well as "mandatory answer" field. The question list view of the template and the event are now almost identical (the button to the stat is obviously not present in the template). Technical remarks: - To ensures that multiple choice answer are filled by the users, we have added an empty choice selected by default which forces the user to choose one option. - Empty answer were already filtered by the server and not inserted in the database (in controller method _process_attendees_form, value evaluated to false are not inserted) Task-2745835 closes odoo/odoo#83586 Signed-off-by: Warnon Aurélien (awa) --- .../views/event_templates_page_registration.xml | 4 ++-- .../models/event_event.py | 1 + .../models/event_question.py | 3 ++- .../views/event_question_views.xml | 10 +++++----- .../views/event_templates.xml | 8 ++++++-- .../views/event_views.xml | 17 ++++++++++------- 6 files changed, 26 insertions(+), 17 deletions(-) diff --git a/addons/website_event/views/event_templates_page_registration.xml b/addons/website_event/views/event_templates_page_registration.xml index d15e0b65b11..ef94ee46210 100644 --- a/addons/website_event/views/event_templates_page_registration.xml +++ b/addons/website_event/views/event_templates_page_registration.xml @@ -288,12 +288,12 @@
Ticket # -
- +
- +
diff --git a/addons/website_event_questions/models/event_event.py b/addons/website_event_questions/models/event_event.py index 85c71355a74..d9b83767b67 100644 --- a/addons/website_event_questions/models/event_event.py +++ b/addons/website_event_questions/models/event_event.py @@ -59,6 +59,7 @@ class EventEvent(models.Model): 'question_type': question.question_type, 'sequence': question.sequence, 'once_per_order': question.once_per_order, + 'is_mandatory_answer': question.is_mandatory_answer, 'answer_ids': [(0, 0, { 'name': answer.name, 'sequence': answer.sequence diff --git a/addons/website_event_questions/models/event_question.py b/addons/website_event_questions/models/event_question.py index 195413c5929..8450cc7c255 100644 --- a/addons/website_event_questions/models/event_question.py +++ b/addons/website_event_questions/models/event_question.py @@ -19,9 +19,10 @@ class EventQuestion(models.Model): event_id = fields.Many2one('event.event', 'Event', ondelete='cascade') answer_ids = fields.One2many('event.question.answer', 'question_id', "Answers", copy=True) sequence = fields.Integer(default=10) - once_per_order = fields.Boolean('Ask only once per order', + once_per_order = fields.Boolean('Ask once per order', help="If True, this question will be asked only once and its value will be propagated to every attendees." "If not it will be asked for every attendee of a reservation.") + is_mandatory_answer = fields.Boolean('Mandatory Answer') @api.constrains('event_type_id', 'event_id') def _constrains_event(self): diff --git a/addons/website_event_questions/views/event_question_views.xml b/addons/website_event_questions/views/event_question_views.xml index 45a511654e9..01d7e499f4a 100644 --- a/addons/website_event_questions/views/event_question_views.xml +++ b/addons/website_event_questions/views/event_question_views.xml @@ -9,11 +9,11 @@

-
- -
- + + +
+ +
diff --git a/addons/website_event_questions/views/event_templates.xml b/addons/website_event_questions/views/event_templates.xml index 21b3428b8b8..f9218de26d9 100644 --- a/addons/website_event_questions/views/event_templates.xml +++ b/addons/website_event_questions/views/event_templates.xml @@ -32,15 +32,19 @@