Skip to content

Commit

Permalink
[16.0][ADD] event_seat_reserve
Browse files Browse the repository at this point in the history
adding translation event_seat_reserve
  • Loading branch information
ilo committed Jul 31, 2024
1 parent ed860ef commit 7da3ca5
Show file tree
Hide file tree
Showing 18 changed files with 892 additions and 0 deletions.
76 changes: 76 additions & 0 deletions event_seat_reserve/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
==================
Event Seat Reserve
==================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:93349cd4baa4e5a7a6b3916bf8e139c0f77b95a7d1aa0b772f5e04a67a218a10
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/16.0/event_seat_reserve
:alt: OCA/event
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/event-16-0/event-16-0-event_seat_reserve
: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=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to make a pre-reserve on registrations.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/event/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 <https://github.com/OCA/event/issues/new?body=module:%20event_seat_reserve%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* Italo LOPES <[email protected]>

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 <https://github.com/OCA/event/tree/16.0/event_seat_reserve>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions event_seat_reserve/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions event_seat_reserve/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).
{
"name": "Event Seat Reserve",
"version": "16.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/event",
"category": "Marketing",
"summary": "Allow pre-reserve registrations",
"depends": ["event"],
"data": [
"views/event_registration.xml",
],
"installable": True,
"auto_install": False,
}
53 changes: 53 additions & 0 deletions event_seat_reserve/i18n/event_seat_reserve.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * event_seat_reserve
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-25 13:30+0000\n"
"PO-Revision-Date: 2024-07-25 13:30+0000\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_seat_reserve
#: model:ir.model,name:event_seat_reserve.model_event_event
msgid "Event"
msgstr ""

#. module: event_seat_reserve
#: model:ir.model,name:event_seat_reserve.model_event_registration
msgid "Event Registration"
msgstr ""

#. module: event_seat_reserve
#: model:ir.model,name:event_seat_reserve.model_event_event_ticket
msgid "Event Ticket"
msgstr ""

#. module: event_seat_reserve
#: model:ir.model.fields,field_description:event_seat_reserve.field_event_event__seats_reserved_unconfirmed
#: model:ir.model.fields,field_description:event_seat_reserve.field_event_event_ticket__seats_reserved_unconfirmed
msgid "Number of Reserved Attendees"
msgstr ""

#. module: event_seat_reserve
#: model:ir.model.fields.selection,name:event_seat_reserve.selection__event_registration__state__reserved
#: model_terms:ir.ui.view,arch_db:event_seat_reserve.view_event_regview_registration_searchistration_form
msgid "Reserved"
msgstr ""

#. module: event_seat_reserve
#: model_terms:ir.ui.view,arch_db:event_seat_reserve.view_event_registration_form
msgid "Set To Reserved"
msgstr ""

#. module: event_seat_reserve
#: model:ir.model.fields,field_description:event_seat_reserve.field_event_registration__state
msgid "Status"
msgstr ""
35 changes: 35 additions & 0 deletions event_seat_reserve/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * event_seat_reserve
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-25 13:30+0000\n"
"PO-Revision-Date: 2024-07-25 13:30+0000\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_seat_reserve
#: model:ir.model.fields,field_description:event_seat_reserve.field_event_event__seats_reserved_unconfirmed
#: model:ir.model.fields,field_description:event_seat_reserve.field_event_event_ticket__seats_reserved_unconfirmed
msgid "Number of Reserved Attendees"
msgstr "Quantité de participants réservés"

#. module: event_seat_reserve
#: model:ir.model.fields.selection,name:event_seat_reserve.selection__event_registration__state__reserved
#: model_terms:ir.ui.view,arch_db:event_seat_reserve.view_event_regview_registration_searchistration_form
msgid "Reserved"
msgstr "Réservé"

#. module: event_seat_reserve
#: model_terms:ir.ui.view,arch_db:event_seat_reserve.view_event_registration_form
msgid "Set To Reserved"
msgstr "Définir comme réservé"


3 changes: 3 additions & 0 deletions event_seat_reserve/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import event_event
from . import event_registration
from . import event_ticket
61 changes: 61 additions & 0 deletions event_seat_reserve/models/event_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).
from odoo import api, fields, models


class EventEvent(models.Model):
_inherit = "event.event"

seats_reserved_unconfirmed = fields.Integer(
string="Number of Reserved Attendees",
store=False,
readonly=True,
compute="_compute_seats",
)

@api.depends("seats_max", "registration_ids.state", "registration_ids.active")
def _compute_seats(self):
# Override the original method to add the new state and the compute for the new field
# initialize fields to 0
for event in self:
event.seats_unconfirmed = (
event.seats_reserved_unconfirmed
) = event.seats_reserved = event.seats_used = event.seats_available = 0
# aggregate registrations by event and by state
state_field = {
"draft": "seats_unconfirmed",
"reserved": "seats_reserved_unconfirmed",
"open": "seats_reserved",
"done": "seats_used",
}
base_vals = {fname: 0 for fname in state_field.values()}
results = {event_id: dict(base_vals) for event_id in self.ids}
if self.ids:
query = """ SELECT event_id, state, count(event_id)
FROM event_registration
WHERE event_id IN %s
AND state IN ('draft', 'reserved', 'open', 'done') AND active = true
GROUP BY event_id, state
"""
self.env["event.registration"].flush_model(["event_id", "state", "active"])
self._cr.execute(query, (tuple(self.ids),))
res = self._cr.fetchall()
for event_id, state, num in res:
results[event_id][state_field[state]] = num

# compute seats_available and expected
for event in self:
event.update(results.get(event._origin.id or event.id, base_vals))
if event.seats_max > 0:
event.seats_available = event.seats_max - (
event.seats_reserved
+ event.seats_used
+ event.seats_reserved_unconfirmed
)

event.seats_expected = (
event.seats_unconfirmed
+ event.seats_reserved_unconfirmed
+ event.seats_reserved
+ event.seats_used
)
17 changes: 17 additions & 0 deletions event_seat_reserve/models/event_registration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).

from odoo import fields, models


class EventRegistration(models.Model):
_inherit = "event.registration"

state = fields.Selection(
selection_add=[("reserved", "Reserved")], ondelete={"reserved": "set default"}
)

def action_set_reserved(self):
self.write({"state": "reserved"})
self.event_id._check_seats_availability()
self.event_ticket_id._check_seats_availability()
51 changes: 51 additions & 0 deletions event_seat_reserve/models/event_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).
from odoo import api, fields, models


class EventTicket(models.Model):
_inherit = "event.event.ticket"

seats_reserved_unconfirmed = fields.Integer(
string="Number of Reserved Attendees", compute="_compute_seats"
)

@api.depends("seats_max", "registration_ids.state", "registration_ids.active")
def _compute_seats(self):
"""Determine reserved, available, reserved but unconfirmed and used seats."""
# initialize fields to 0 + compute seats availability
for ticket in self:
ticket.seats_unconfirmed = (

Check warning on line 18 in event_seat_reserve/models/event_ticket.py

View check run for this annotation

Codecov / codecov/patch

event_seat_reserve/models/event_ticket.py#L18

Added line #L18 was not covered by tests
ticket.seats_reserved
) = ticket.seats_used = ticket.seats_available = 0
# aggregate registrations by ticket and by state
results = {}

Check warning on line 22 in event_seat_reserve/models/event_ticket.py

View check run for this annotation

Codecov / codecov/patch

event_seat_reserve/models/event_ticket.py#L22

Added line #L22 was not covered by tests
if self.ids:
state_field = {

Check warning on line 24 in event_seat_reserve/models/event_ticket.py

View check run for this annotation

Codecov / codecov/patch

event_seat_reserve/models/event_ticket.py#L24

Added line #L24 was not covered by tests
"draft": "seats_unconfirmed",
"reserved": "seats_reserved_unconfirmed",
"open": "seats_reserved",
"done": "seats_used",
}
query = """ SELECT event_ticket_id, state, count(event_id)

Check warning on line 30 in event_seat_reserve/models/event_ticket.py

View check run for this annotation

Codecov / codecov/patch

event_seat_reserve/models/event_ticket.py#L30

Added line #L30 was not covered by tests
FROM event_registration
WHERE event_ticket_id IN %s
AND state IN ('draft', 'reserved', 'open', 'done') AND active = true
GROUP BY event_ticket_id, state
"""
self.env["event.registration"].flush_model(

Check warning on line 36 in event_seat_reserve/models/event_ticket.py

View check run for this annotation

Codecov / codecov/patch

event_seat_reserve/models/event_ticket.py#L36

Added line #L36 was not covered by tests
["event_id", "event_ticket_id", "state", "active"]
)
self.env.cr.execute(query, (tuple(self.ids),))

Check warning on line 39 in event_seat_reserve/models/event_ticket.py

View check run for this annotation

Codecov / codecov/patch

event_seat_reserve/models/event_ticket.py#L39

Added line #L39 was not covered by tests
for event_ticket_id, state, num in self.env.cr.fetchall():
results.setdefault(event_ticket_id, {})[state_field[state]] = num

Check warning on line 41 in event_seat_reserve/models/event_ticket.py

View check run for this annotation

Codecov / codecov/patch

event_seat_reserve/models/event_ticket.py#L41

Added line #L41 was not covered by tests

# compute seats_available
for ticket in self:
ticket.update(results.get(ticket._origin.id or ticket.id, {}))

Check warning on line 45 in event_seat_reserve/models/event_ticket.py

View check run for this annotation

Codecov / codecov/patch

event_seat_reserve/models/event_ticket.py#L45

Added line #L45 was not covered by tests
if ticket.seats_max > 0:
ticket.seats_available = ticket.seats_max - (

Check warning on line 47 in event_seat_reserve/models/event_ticket.py

View check run for this annotation

Codecov / codecov/patch

event_seat_reserve/models/event_ticket.py#L47

Added line #L47 was not covered by tests
ticket.seats_reserved
+ ticket.seats_used
+ ticket.seats_reserved_unconfirmed
)
1 change: 1 addition & 0 deletions event_seat_reserve/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Italo LOPES <[email protected]>
1 change: 1 addition & 0 deletions event_seat_reserve/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to make a pre-reserve on registrations.
Binary file added event_seat_reserve/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7da3ca5

Please sign in to comment.