-
-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][ADD] event_seat_reserve #394
base: 16.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 <italo.lopes@camptocamp.com> | ||
|
||
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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
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, | ||
} |
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 "" |
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é" | ||
|
||
|
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# 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 | ||
imlopes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# initialize fields to 0 | ||
res = super()._compute_seats() | ||
counts = dict() | ||
if self.ids: | ||
groups = self.env["event.registration"].read_group( | ||
[ | ||
("event_id", "in", self.ids), | ||
("state", "=", "reserved"), | ||
], | ||
groupby=["event_id"], | ||
fields=["event_id"], | ||
) | ||
counts = {g["event_id"][0]: g["event_id_count"] for g in groups} | ||
|
||
# compute seats_available and expected | ||
for event in self: | ||
event.seats_reserved_unconfirmed = counts.get(event.id, 0) | ||
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 | ||
) | ||
return res |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). | ||
import logging | ||
|
||
from odoo import fields, models | ||
from odoo.tools import config | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class EventRegistration(models.Model): | ||
_inherit = "event.registration" | ||
|
||
state = fields.Selection( | ||
selection_add=[("reserved", "Reserved"), ("open",)], | ||
ondelete={"reserved": "set default"}, | ||
) | ||
|
||
def action_set_reserved(self): | ||
if config["test_enable"] and not self.env.context.get( | ||
"test_event_seat_reserve" | ||
): | ||
_logger.info("Test mode is enabled, you cannot reserve a registration.") | ||
return True | ||
Comment on lines
+20
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some tests are failing on the two others PR's because when create a sale, normally the |
||
self.write({"state": "reserved"}) | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
confirming = vals.get("state") == "reserved" | ||
if confirming: | ||
self.event_id._check_seats_availability() | ||
self.event_ticket_id._check_seats_availability() | ||
return res |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 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.""" | ||
imlopes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# initialize fields to 0 + compute seats availability | ||
res = super()._compute_seats() | ||
counts = dict() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This compute method is not covered by tests. |
||
if self.ids: | ||
groups = self.env["event.registration"].read_group( | ||
[ | ||
("event_ticket_id", "in", self.ids), | ||
("state", "=", "reserved"), | ||
], | ||
groupby=["event_ticket_id"], | ||
fields=["event_ticket_id"], | ||
) | ||
counts = { | ||
g["event_ticket_id"][0]: g["event_ticket_id_count"] for g in groups | ||
} | ||
|
||
# compute seats_available | ||
for ticket in self: | ||
ticket.seats_reserved_unconfirmed = counts.get(ticket.id, 0) | ||
if ticket.seats_max > 0: | ||
ticket.seats_available = ticket.seats_max - ( | ||
ticket.seats_reserved | ||
+ ticket.seats_used | ||
+ ticket.seats_reserved_unconfirmed | ||
) | ||
return res | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Italo LOPES <italo.lopes@camptocamp.com> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module allows to make a pre-reserve on registrations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.