diff --git a/event_min_seat/README.rst b/event_min_seat/README.rst new file mode 100644 index 000000000..c21b5094d --- /dev/null +++ b/event_min_seat/README.rst @@ -0,0 +1,81 @@ +======================= +Minimum seats in events +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3f299706cc21954b302192582780535e45052114a0eb5b5aecaae131b1e4b011 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github + :target: https://github.com/OCA/event/tree/17.0/event_min_seat + :alt: OCA/event +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/event-17-0/event-17-0-event_min_seat + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/event&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module recovers the lost feature for specifying the minimum seats +required for an event, and showing such events on red in the list view +if the minimum seats are not satisfied. + +**Table of contents** + +.. contents:: + :local: + +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 to smash 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 + - Pilar Vargas + +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/event_min_seat/__init__.py b/event_min_seat/__init__.py new file mode 100644 index 000000000..02179fb04 --- /dev/null +++ b/event_min_seat/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import models diff --git a/event_min_seat/__manifest__.py b/event_min_seat/__manifest__.py new file mode 100644 index 000000000..07f819ce0 --- /dev/null +++ b/event_min_seat/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2023 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Minimum seats in events", + "version": "17.0.1.0.0", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/event", + "category": "Marketing", + "depends": ["event"], + "data": [ + "views/event_event_views.xml", + "views/event_type_views.xml", + ], + "installable": True, +} diff --git a/event_min_seat/i18n/es.po b/event_min_seat/i18n/es.po new file mode 100644 index 000000000..104e24e70 --- /dev/null +++ b/event_min_seat/i18n/es.po @@ -0,0 +1,73 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * event_min_seat +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-08-03 18:13+0000\n" +"PO-Revision-Date: 2023-10-29 23:38+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: event_min_seat +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_form +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_type_form +msgid " " +msgstr " " + +#. module: event_min_seat +#: model:ir.model,name:event_min_seat.model_event_event +msgid "Event" +msgstr "Evento" + +#. module: event_min_seat +#: model:ir.model,name:event_min_seat.model_event_type +msgid "Event Template" +msgstr "Plantilla de evento" + +#. module: event_min_seat +#: model:ir.model.fields,help:event_min_seat.field_event_event__seats_min +msgid "" +"For each event you can define a minimum reserved seats (number of " +"attendees). If it does not reach the mentioned registrations, the event is " +"highlighted in the list." +msgstr "" +"Para cada evento, puede definir un mínimo de sitios reservados (número de " +"asistentes). Si no alcanza los registros mencionados, el evento será " +"resaltado en la lista." + +#. module: event_min_seat +#: model:ir.model.fields,help:event_min_seat.field_event_type__default_registration_min +msgid "It will select this default minimum value when you choose this event" +msgstr "Seleccionará este valor mínimo por defecto cuando escoja este evento" + +#. module: event_min_seat +#: code:addons/event_min_seat/models/event_event.py:0 +#, python-format +msgid "" +"Maximum attendees number should be greater than minimum attendees number." +msgstr "El número máximo de asistentes debe ser mayor que el mínimo." + +#. module: event_min_seat +#: model:ir.model.fields,field_description:event_min_seat.field_event_type__default_registration_min +msgid "Minimum Registrations" +msgstr "Registros mínimos" + +#. module: event_min_seat +#: model:ir.model.fields,field_description:event_min_seat.field_event_event__seats_min +msgid "Minimum Seats" +msgstr "Asientos mínimos" + +#. module: event_min_seat +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_form +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_type_form +msgid "from" +msgstr "desde" diff --git a/event_min_seat/i18n/event_min_seat.pot b/event_min_seat/i18n/event_min_seat.pot new file mode 100644 index 000000000..6196e73d8 --- /dev/null +++ b/event_min_seat/i18n/event_min_seat.pot @@ -0,0 +1,66 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * event_min_seat +# +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: event_min_seat +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_form +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_type_form +msgid " " +msgstr "" + +#. module: event_min_seat +#: model:ir.model,name:event_min_seat.model_event_event +msgid "Event" +msgstr "" + +#. module: event_min_seat +#: model:ir.model,name:event_min_seat.model_event_type +msgid "Event Template" +msgstr "" + +#. module: event_min_seat +#: model:ir.model.fields,help:event_min_seat.field_event_event__seats_min +msgid "" +"For each event you can define a minimum reserved seats (number of " +"attendees). If it does not reach the mentioned registrations, the event is " +"highlighted in the list." +msgstr "" + +#. module: event_min_seat +#: model:ir.model.fields,help:event_min_seat.field_event_type__default_registration_min +msgid "It will select this default minimum value when you choose this event" +msgstr "" + +#. module: event_min_seat +#: code:addons/event_min_seat/models/event_event.py:0 +#, python-format +msgid "" +"Maximum attendees number should be greater than minimum attendees number." +msgstr "" + +#. module: event_min_seat +#: model:ir.model.fields,field_description:event_min_seat.field_event_type__default_registration_min +msgid "Minimum Registrations" +msgstr "" + +#. module: event_min_seat +#: model:ir.model.fields,field_description:event_min_seat.field_event_event__seats_min +msgid "Minimum Seats" +msgstr "" + +#. module: event_min_seat +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_form +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_type_form +msgid "from" +msgstr "" diff --git a/event_min_seat/i18n/it.po b/event_min_seat/i18n/it.po new file mode 100644 index 000000000..809178bb9 --- /dev/null +++ b/event_min_seat/i18n/it.po @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * event_min_seat +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-22 09:35+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: event_min_seat +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_form +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_type_form +msgid " " +msgstr " " + +#. module: event_min_seat +#: model:ir.model,name:event_min_seat.model_event_event +msgid "Event" +msgstr "Evento" + +#. module: event_min_seat +#: model:ir.model,name:event_min_seat.model_event_type +msgid "Event Template" +msgstr "Modello evento" + +#. module: event_min_seat +#: model:ir.model.fields,help:event_min_seat.field_event_event__seats_min +msgid "" +"For each event you can define a minimum reserved seats (number of " +"attendees). If it does not reach the mentioned registrations, the event is " +"highlighted in the list." +msgstr "" +"Per ogni evento si può definire un numero minimo di posti prenotati (numero " +"di partecipanti). Se non si raggiungono le registrazioni indicate, l'evento " +"verrà evidenziato nell'elenco." + +#. module: event_min_seat +#: model:ir.model.fields,help:event_min_seat.field_event_type__default_registration_min +msgid "It will select this default minimum value when you choose this event" +msgstr "" +"Verrà selezionato questo numero minimo predefinito quando si sceglie questo " +"evento" + +#. module: event_min_seat +#: code:addons/event_min_seat/models/event_event.py:0 +#, python-format +msgid "" +"Maximum attendees number should be greater than minimum attendees number." +msgstr "" +"Il numero massimo di partecipanti deve essere superiore al numero minimo di " +"partecipanti." + +#. module: event_min_seat +#: model:ir.model.fields,field_description:event_min_seat.field_event_type__default_registration_min +msgid "Minimum Registrations" +msgstr "Registrazioni minime" + +#. module: event_min_seat +#: model:ir.model.fields,field_description:event_min_seat.field_event_event__seats_min +msgid "Minimum Seats" +msgstr "Posti minimi" + +#. module: event_min_seat +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_form +#: model_terms:ir.ui.view,arch_db:event_min_seat.view_event_type_form +msgid "from" +msgstr "dal" diff --git a/event_min_seat/models/__init__.py b/event_min_seat/models/__init__.py new file mode 100644 index 000000000..45795a053 --- /dev/null +++ b/event_min_seat/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import event_event +from . import event_type diff --git a/event_min_seat/models/event_event.py b/event_min_seat/models/event_event.py new file mode 100644 index 000000000..165f502c4 --- /dev/null +++ b/event_min_seat/models/event_event.py @@ -0,0 +1,34 @@ +# Copyright 2023 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import _, api, exceptions, fields, models + + +class EventEvent(models.Model): + _inherit = "event.event" + + seats_min = fields.Integer( + string="Minimum Seats", + compute="_compute_seats_min", + readonly=False, + store=True, + help="For each event you can define a minimum reserved seats (number of " + "attendees). If it does not reach the mentioned registrations, the event is " + "highlighted in the list.", + ) + + @api.depends("event_type_id") + def _compute_seats_min(self): + for event in self.filtered("event_type_id"): + event.seats_min = event.event_type_id.default_registration_min + + @api.constrains("seats_min", "seats_max", "seats_limited") + def _check_seats_min_max(self): + if any( + event.seats_limited and event.seats_min > event.seats_max for event in self + ): + raise exceptions.ValidationError( + _( + "Maximum attendees number should be greater than minimum attendees " + "number." + ) + ) diff --git a/event_min_seat/models/event_type.py b/event_min_seat/models/event_type.py new file mode 100644 index 000000000..7ff556115 --- /dev/null +++ b/event_min_seat/models/event_type.py @@ -0,0 +1,19 @@ +# Copyright 2023 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class EventType(models.Model): + _inherit = "event.type" + + default_registration_min = fields.Integer( + "Minimum Registrations", + compute="_compute_default_registration_min", + readonly=False, + store=True, + help="It will select this default minimum value when you choose this event", + ) + + @api.depends("has_seats_limitation") + def _compute_default_registration_min(self): + self.filtered(lambda x: not x.has_seats_limitation).default_registration_min = 0 diff --git a/event_min_seat/pyproject.toml b/event_min_seat/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/event_min_seat/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/event_min_seat/readme/CONTRIBUTORS.md b/event_min_seat/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..baf1f43f5 --- /dev/null +++ b/event_min_seat/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- [Tecnativa](https://www.tecnativa.com): + + > - Pedro M. Baeza + > - Pilar Vargas diff --git a/event_min_seat/readme/DESCRIPTION.md b/event_min_seat/readme/DESCRIPTION.md new file mode 100644 index 000000000..b96c188c9 --- /dev/null +++ b/event_min_seat/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module recovers the lost feature for specifying the minimum seats +required for an event, and showing such events on red in the list view +if the minimum seats are not satisfied. diff --git a/event_min_seat/static/description/icon.png b/event_min_seat/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/event_min_seat/static/description/icon.png differ diff --git a/event_min_seat/static/description/index.html b/event_min_seat/static/description/index.html new file mode 100644 index 000000000..33f792de5 --- /dev/null +++ b/event_min_seat/static/description/index.html @@ -0,0 +1,432 @@ + + + + + +Minimum seats in events + + + +
+

Minimum seats in events

+ + +

Beta License: AGPL-3 OCA/event Translate me on Weblate Try me on Runboat

+

This module recovers the lost feature for specifying the minimum seats +required for an event, and showing such events on red in the list view +if the minimum seats are not satisfied.

+

Table of contents

+ +
+

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 to smash 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
    • +
    • Pilar Vargas
    • +
    +
    +
  • +
+
+
+

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/event_min_seat/tests/__init__.py b/event_min_seat/tests/__init__.py new file mode 100644 index 000000000..64dc222a4 --- /dev/null +++ b/event_min_seat/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import test_event_min_seat diff --git a/event_min_seat/tests/test_event_min_seat.py b/event_min_seat/tests/test_event_min_seat.py new file mode 100644 index 000000000..4a7308462 --- /dev/null +++ b/event_min_seat/tests/test_event_min_seat.py @@ -0,0 +1,42 @@ +# Copyright 2023 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import exceptions +from odoo.tests.common import TransactionCase + + +class TestEventMinSeat(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.event_type = cls.env["event.type"].create( + { + "name": "Test event type", + "has_seats_limitation": True, + "default_registration_min": 5, + "seats_max": 10, + } + ) + cls.event_type_default = cls.env["event.type"].create( + {"name": "Test event type default"} + ) + cls.event = cls.env["event.event"].create( + { + "name": "Test event", + "event_type_id": cls.event_type_default.id, + "date_begin": "2023-01-01", + "date_end": "2023-01-01", + } + ) + + def test_event_type_no_has_seats_limitation(self): + self.event_type.has_seats_limitation = False + self.assertEqual(self.event_type.default_registration_min, 0) + + def test_event_propagation_from_type(self): + self.event.event_type_id = self.event_type.id + self.assertEqual(self.event.seats_min, 5) + + def test_check_seats_min_max(self): + self.event.write({"seats_max": 5, "seats_limited": True}) + with self.assertRaises(exceptions.ValidationError): + self.event.seats_min = 6 diff --git a/event_min_seat/views/event_event_views.xml b/event_min_seat/views/event_event_views.xml new file mode 100644 index 000000000..023f9523a --- /dev/null +++ b/event_min_seat/views/event_event_views.xml @@ -0,0 +1,29 @@ + + + event.event + + + + from + &nbsp; + + + + + event.event + + + + (seats_min and seats_min > seats_reserved) or (seats_max and seats_max < seats_reserved) + + + + + + + diff --git a/event_min_seat/views/event_type_views.xml b/event_min_seat/views/event_type_views.xml new file mode 100644 index 000000000..4db4c6d60 --- /dev/null +++ b/event_min_seat/views/event_type_views.xml @@ -0,0 +1,17 @@ + + + event.type + + + + + from + &nbsp; + + + + +