-
-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding translation event_seat_reserve
- Loading branch information
ilo
committed
Jul 31, 2024
1 parent
ed860ef
commit 7da3ca5
Showing
18 changed files
with
892 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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é" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ( | ||
ticket.seats_reserved | ||
) = ticket.seats_used = ticket.seats_available = 0 | ||
# aggregate registrations by ticket and by state | ||
results = {} | ||
if self.ids: | ||
state_field = { | ||
"draft": "seats_unconfirmed", | ||
"reserved": "seats_reserved_unconfirmed", | ||
"open": "seats_reserved", | ||
"done": "seats_used", | ||
} | ||
query = """ SELECT event_ticket_id, state, count(event_id) | ||
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( | ||
["event_id", "event_ticket_id", "state", "active"] | ||
) | ||
self.env.cr.execute(query, (tuple(self.ids),)) | ||
for event_ticket_id, state, num in self.env.cr.fetchall(): | ||
results.setdefault(event_ticket_id, {})[state_field[state]] = num | ||
|
||
# compute seats_available | ||
for ticket in self: | ||
ticket.update(results.get(ticket._origin.id or ticket.id, {})) | ||
if ticket.seats_max > 0: | ||
ticket.seats_available = ticket.seats_max - ( | ||
ticket.seats_reserved | ||
+ ticket.seats_used | ||
+ ticket.seats_reserved_unconfirmed | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Italo LOPES <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module allows to make a pre-reserve on registrations. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.