diff --git a/website_event_questions_by_ticket/README.rst b/website_event_questions_by_ticket/README.rst new file mode 100644 index 000000000..c1988da63 --- /dev/null +++ b/website_event_questions_by_ticket/README.rst @@ -0,0 +1,105 @@ +============================ +Conditional Events Questions +============================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github + :target: https://github.com/OCA/event/tree/15.0/website_event_questions_by_ticket + :alt: OCA/event +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/event-15-0/event-15-0-website_event_questions_by_ticket + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/199/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to set that an event question is only asked for certain +tickets. + +If the question is general, then having one of the allowed tickets will serve +for showing it. If the question is specific to each attendee, then the +evaluation will be done for each of the tickets. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +#. Go to *Events > Events* +#. Create or select one event. +#. On the "Questions" page, create a new question or edit an existing one. +#. Fill the field "Limited to tickets" for restricting the question to that + ticket. Leave it blank for making it available for all tickets. + +Usage +===== + + +#. Go to the website. +#. Go to "Events" section and select one of them. +#. Select ticket quantity and click on "Register". +#. On the popup dialog, the questions linked to that ticket and those without + restrictions will be shown. + +Known issues / Roadmap +====================== + +* Add tests (tour) to the module. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Pedro M. Baeza + * Stefan Ungureanu + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/event `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_event_questions_by_ticket/__init__.py b/website_event_questions_by_ticket/__init__.py new file mode 100644 index 000000000..7d768b54b --- /dev/null +++ b/website_event_questions_by_ticket/__init__.py @@ -0,0 +1,3 @@ +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from . import models diff --git a/website_event_questions_by_ticket/__manifest__.py b/website_event_questions_by_ticket/__manifest__.py new file mode 100644 index 000000000..1142af98b --- /dev/null +++ b/website_event_questions_by_ticket/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2019 Tecnativa - Pedro M. Baeza +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +{ + "name": "Conditional Events Questions", + "summary": "Events Questions conditional to the chosen ticket", + "version": "16.0.1.0.0", + "category": "Website", + "website": "https://github.com/OCA/event", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "LGPL-3", + "installable": True, + "depends": ["website_event_sale", "website_event_questions"], + "data": ["views/event_event_views.xml", "views/event_templates.xml"], +} diff --git a/website_event_questions_by_ticket/i18n/es.po b/website_event_questions_by_ticket/i18n/es.po new file mode 100644 index 000000000..03e2d9839 --- /dev/null +++ b/website_event_questions_by_ticket/i18n/es.po @@ -0,0 +1,56 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_event_questions_by_ticket +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-03-17 14:45+0000\n" +"Last-Translator: Ana Suárez \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: website_event_questions_by_ticket +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_event__display_name +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_question__display_name +msgid "Display Name" +msgstr "" + +#. module: website_event_questions_by_ticket +#: model:ir.model,name:website_event_questions_by_ticket.model_event_event +msgid "Event" +msgstr "Evento" + +#. module: website_event_questions_by_ticket +#: model:ir.model,name:website_event_questions_by_ticket.model_event_question +msgid "Event Question" +msgstr "Pregunta Evento" + +#. module: website_event_questions_by_ticket +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_event__id +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_question__id +msgid "ID" +msgstr "" + +#. module: website_event_questions_by_ticket +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_event____last_update +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_question____last_update +msgid "Last Modified on" +msgstr "" + +#. module: website_event_questions_by_ticket +#: model_terms:ir.ui.view,arch_db:website_event_questions_by_ticket.view_event_question_form +msgid "Leave it empty for being available for all tickets" +msgstr "Dejar vacío para estar disponible para todos los tickets" + +#. module: website_event_questions_by_ticket +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_question__restricted_ticket_ids +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_question_template_question__restricted_ticket_ids +msgid "Limited to tickets" +msgstr "Limitado a tickets" diff --git a/website_event_questions_by_ticket/i18n/it.po b/website_event_questions_by_ticket/i18n/it.po new file mode 100644 index 000000000..32d01768f --- /dev/null +++ b/website_event_questions_by_ticket/i18n/it.po @@ -0,0 +1,56 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_event_questions_by_ticket +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-07-18 14:11+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: website_event_questions_by_ticket +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_event__display_name +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_question__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: website_event_questions_by_ticket +#: model:ir.model,name:website_event_questions_by_ticket.model_event_event +msgid "Event" +msgstr "Evento" + +#. module: website_event_questions_by_ticket +#: model:ir.model,name:website_event_questions_by_ticket.model_event_question +msgid "Event Question" +msgstr "Domanda evento" + +#. module: website_event_questions_by_ticket +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_event__id +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_question__id +msgid "ID" +msgstr "ID" + +#. module: website_event_questions_by_ticket +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_event____last_update +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_question____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: website_event_questions_by_ticket +#: model_terms:ir.ui.view,arch_db:website_event_questions_by_ticket.view_event_question_form +msgid "Leave it empty for being available for all tickets" +msgstr "Lasciare vuoto per renderlo disponibile per tutti i biglietti" + +#. module: website_event_questions_by_ticket +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_question__restricted_ticket_ids +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_question_template_question__restricted_ticket_ids +msgid "Limited to tickets" +msgstr "Limitato ai biglietti" diff --git a/website_event_questions_by_ticket/i18n/website_event_questions_by_ticket.pot b/website_event_questions_by_ticket/i18n/website_event_questions_by_ticket.pot new file mode 100644 index 000000000..4ddae7bc7 --- /dev/null +++ b/website_event_questions_by_ticket/i18n/website_event_questions_by_ticket.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_event_questions_by_ticket +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: website_event_questions_by_ticket +#: model:ir.model,name:website_event_questions_by_ticket.model_event_event +msgid "Event" +msgstr "" + +#. module: website_event_questions_by_ticket +#: model:ir.model,name:website_event_questions_by_ticket.model_event_question +msgid "Event Question" +msgstr "" + +#. module: website_event_questions_by_ticket +#: model_terms:ir.ui.view,arch_db:website_event_questions_by_ticket.view_event_question_form +msgid "Leave it empty for being available for all tickets" +msgstr "" + +#. module: website_event_questions_by_ticket +#: model:ir.model.fields,field_description:website_event_questions_by_ticket.field_event_question__restricted_ticket_ids +msgid "Limited to tickets" +msgstr "" diff --git a/website_event_questions_by_ticket/models/__init__.py b/website_event_questions_by_ticket/models/__init__.py new file mode 100644 index 000000000..444d27961 --- /dev/null +++ b/website_event_questions_by_ticket/models/__init__.py @@ -0,0 +1,3 @@ +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from . import event_event diff --git a/website_event_questions_by_ticket/models/event_event.py b/website_event_questions_by_ticket/models/event_event.py new file mode 100644 index 000000000..8b7ac1c1f --- /dev/null +++ b/website_event_questions_by_ticket/models/event_event.py @@ -0,0 +1,36 @@ +# Copyright 2019 Tecnativa - Pedro M. Baeza +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class EventEvent(models.Model): + _inherit = "event.event" + + def _get_specific_questions(self, ticket_id): + self.ensure_one() + return self.specific_question_ids.filtered( + lambda x: ( + not x.restricted_ticket_ids or ticket_id in x.restricted_ticket_ids.ids + ) + ) + + def _get_general_questions(self, ticket_ids): + self.ensure_one() + return self.general_question_ids.filtered( + lambda x: ( + not x.restricted_ticket_ids + or (set(ticket_ids) & set(x.restricted_ticket_ids.ids)) + ) + ) + + +class EventQuestion(models.Model): + _inherit = "event.question" + + restricted_ticket_ids = fields.Many2many( + comodel_name="event.event.ticket", + string="Limited to tickets", + domain="[('event_id', '=', parent.id)]", + ondelete="restrict", + ) diff --git a/website_event_questions_by_ticket/readme/CONFIGURE.rst b/website_event_questions_by_ticket/readme/CONFIGURE.rst new file mode 100644 index 000000000..926c7afe0 --- /dev/null +++ b/website_event_questions_by_ticket/readme/CONFIGURE.rst @@ -0,0 +1,5 @@ +#. Go to *Events > Events* +#. Create or select one event. +#. On the "Questions" page, create a new question or edit an existing one. +#. Fill the field "Limited to tickets" for restricting the question to that + ticket. Leave it blank for making it available for all tickets. diff --git a/website_event_questions_by_ticket/readme/CONTRIBUTORS.rst b/website_event_questions_by_ticket/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..8f9a5be43 --- /dev/null +++ b/website_event_questions_by_ticket/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_: + + * Pedro M. Baeza + * Stefan Ungureanu diff --git a/website_event_questions_by_ticket/readme/DESCRIPTION.rst b/website_event_questions_by_ticket/readme/DESCRIPTION.rst new file mode 100644 index 000000000..592216245 --- /dev/null +++ b/website_event_questions_by_ticket/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module allows to set that an event question is only asked for certain +tickets. + +If the question is general, then having one of the allowed tickets will serve +for showing it. If the question is specific to each attendee, then the +evaluation will be done for each of the tickets. diff --git a/website_event_questions_by_ticket/readme/ROADMAP.rst b/website_event_questions_by_ticket/readme/ROADMAP.rst new file mode 100644 index 000000000..351e76b9e --- /dev/null +++ b/website_event_questions_by_ticket/readme/ROADMAP.rst @@ -0,0 +1 @@ +* Add tests (tour) to the module. diff --git a/website_event_questions_by_ticket/readme/USAGE.rst b/website_event_questions_by_ticket/readme/USAGE.rst new file mode 100644 index 000000000..64f4e7a33 --- /dev/null +++ b/website_event_questions_by_ticket/readme/USAGE.rst @@ -0,0 +1,6 @@ + +#. Go to the website. +#. Go to "Events" section and select one of them. +#. Select ticket quantity and click on "Register". +#. On the popup dialog, the questions linked to that ticket and those without + restrictions will be shown. diff --git a/website_event_questions_by_ticket/static/description/icon.png b/website_event_questions_by_ticket/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/website_event_questions_by_ticket/static/description/icon.png differ diff --git a/website_event_questions_by_ticket/static/description/index.html b/website_event_questions_by_ticket/static/description/index.html new file mode 100644 index 000000000..55e93e3db --- /dev/null +++ b/website_event_questions_by_ticket/static/description/index.html @@ -0,0 +1,456 @@ + + + + + + +Conditional Events Questions + + + +
+

Conditional Events Questions

+ + +

Beta License: LGPL-3 OCA/event Translate me on Weblate Try me on Runbot

+

This module allows to set that an event question is only asked for certain +tickets.

+

If the question is general, then having one of the allowed tickets will serve +for showing it. If the question is specific to each attendee, then the +evaluation will be done for each of the tickets.

+

Table of contents

+ +
+

Configuration

+
    +
  1. Go to Events > Events
  2. +
  3. Create or select one event.
  4. +
  5. On the “Questions” page, create a new question or edit an existing one.
  6. +
  7. Fill the field “Limited to tickets” for restricting the question to that +ticket. Leave it blank for making it available for all tickets.
  8. +
+
+
+

Usage

+
    +
  1. Go to the website.
  2. +
  3. Go to “Events” section and select one of them.
  4. +
  5. Select ticket quantity and click on “Register”.
  6. +
  7. On the popup dialog, the questions linked to that ticket and those without +restrictions will be shown.
  8. +
+
+
+

Known issues / Roadmap

+
    +
  • Add tests (tour) to the module.
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Pedro M. Baeza
    • +
    • Stefan Ungureanu
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/event project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/website_event_questions_by_ticket/tests/__init__.py b/website_event_questions_by_ticket/tests/__init__.py new file mode 100644 index 000000000..19366179f --- /dev/null +++ b/website_event_questions_by_ticket/tests/__init__.py @@ -0,0 +1 @@ +from . import test_ticket diff --git a/website_event_questions_by_ticket/tests/test_ticket.py b/website_event_questions_by_ticket/tests/test_ticket.py new file mode 100644 index 000000000..a709ac6f7 --- /dev/null +++ b/website_event_questions_by_ticket/tests/test_ticket.py @@ -0,0 +1,52 @@ +# Copyright 2020 Studio73 - Ioan Galan +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from dateutil.relativedelta import relativedelta + +from odoo import fields +from odoo.tests import HttpCase + + +class TestTicket(HttpCase): + def setUp(self): + super().setUp() + now = fields.Datetime.now() + self.website = self.env["website"].browse(1) + self.event_question_free_text = "Free Text" + self.event_1 = self.env["event.event"].create( + { + "name": "Event One", + "user_id": self.env.ref("base.user_admin").id, + "date_begin": now + relativedelta(days=1), + "date_end": now + relativedelta(days=3), + "organizer_id": self.env.ref("base.res_partner_1").id, + "event_type_id": self.env.ref("event.event_type_1").id, + "website_published": True, + "description": "Test", + "auto_confirm": True, + "website_id": self.website.id, + } + ) + self.ticket_1 = self.env["event.event.ticket"].create( + {"name": "Ticket One", "event_id": self.event_1.id} + ) + self.ticket_2 = self.env["event.event.ticket"].create( + {"name": "Ticket Two", "event_id": self.event_1.id} + ) + self.question_1 = self.env["event.question"].create( + { + "title": "Question Two", + "event_id": self.event_1.id, + "restricted_ticket_ids": [(6, 0, self.ticket_1.ids)], + } + ) + + def test_specific_questions(self): + specific_questions = self.event_1._get_specific_questions(self.ticket_1.id) + self.assertTrue(self.question_1 in specific_questions) + return True + + def test_general_questions(self): + general_questions = self.event_1._get_general_questions(self.ticket_2.ids) + self.assertFalse(self.question_1 in general_questions) + return True diff --git a/website_event_questions_by_ticket/views/event_event_views.xml b/website_event_questions_by_ticket/views/event_event_views.xml new file mode 100644 index 000000000..a3516172b --- /dev/null +++ b/website_event_questions_by_ticket/views/event_event_views.xml @@ -0,0 +1,35 @@ + + + + + event.event + + + + + + + + + + + event.event + + + + + + + + diff --git a/website_event_questions_by_ticket/views/event_templates.xml b/website_event_questions_by_ticket/views/event_templates.xml new file mode 100644 index 000000000..016bed0b2 --- /dev/null +++ b/website_event_questions_by_ticket/views/event_templates.xml @@ -0,0 +1,37 @@ + + + + +