Skip to content

Commit

Permalink
Merge PR #223 into 13.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Jun 3, 2021
2 parents 1ad54ba + fe0f266 commit 0a49511
Show file tree
Hide file tree
Showing 18 changed files with 898 additions and 0 deletions.
98 changes: 98 additions & 0 deletions event_registration_multi_qty/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
============================
Event Registration Multi Qty
============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-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/13.0/event_registration_multi_qty
:alt: OCA/event
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/event-13-0/event-13-0-event_registration_multi_qty
: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/13.0
:alt: Try me on Runbot

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

This module allows to make registration to events with more than one attendee.

This was the unique behavior on versions 8 and 9. As it's useful for some use
cases, this module allows both ways of registering attendees.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure the possibility of registering mutiple attendees:

#. Go to *Events > Events*.
#. Create one event.
#. Go to *Registration tab* and check "Registration Multi Qty" to activate
this function.

Usage
=====

For registering multiple attendees:

#. Create an attendee for the created event.
#. Write the quantities for this registration.

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/event/issues/new?body=module:%20event_registration_multi_qty%0Aversion:%2013.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
~~~~~~~

* Tecnativa

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

* `Tecnativa <https://www.tecnativa.com>`__:

* Sergio Teruel
* Pedro M. Baeza
* David Vidal

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/13.0/event_registration_multi_qty>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions event_registration_multi_qty/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import tests
14 changes: 14 additions & 0 deletions event_registration_multi_qty/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2017 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Event Registration Multi Qty",
"version": "13.0.1.0.0",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://www.github.com/event",
"category": "Marketing",
"summary": "Allow registration grouped by quantities",
"depends": ["event"],
"data": ["views/event_view.xml"],
"installable": True,
}
62 changes: 62 additions & 0 deletions event_registration_multi_qty/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * event_registration_multi_qty
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-02 16:29+0200\n"
"PO-Revision-Date: 2019-02-01 14:03+0000\n"
"Last-Translator: Marta Vázquez Rodríguez <vazrodmar@gmail.com>\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 3.4\n"

#. module: event_registration_multi_qty
#: model:ir.model.fields,field_description:event_registration_multi_qty.field_event_event__registration_multi_qty
msgid "Allow multiple attendees per registration"
msgstr "Permitir múltiples asistentes por registro"

#. module: event_registration_multi_qty
#: model:ir.model,name:event_registration_multi_qty.model_event_event
msgid "Event"
msgstr "Evento"

#. module: event_registration_multi_qty
#: model:ir.model,name:event_registration_multi_qty.model_event_registration
#, fuzzy
msgid "Event Registration"
msgstr "report.event.registration"

#. module: event_registration_multi_qty
#: model:ir.model.fields,field_description:event_registration_multi_qty.field_event_registration__qty
msgid "Quantity"
msgstr "Cantidad"

#. module: event_registration_multi_qty
#: code:addons/event_registration_multi_qty/models/event.py:77
#, python-format
msgid ""
"You can not add quantities if you not active the option \"Allow multiple "
"attendees per registration\" in event"
msgstr ""
"No puedes añadir cantidades de registro si no tienes marcada la opción "
"\"Permitir múltiples asistentes en el registro\" en el evento"

#. module: event_registration_multi_qty
#: code:addons/event_registration_multi_qty/models/event.py:57
#, python-format
msgid ""
"You can not disable this option if there are registrations with quantities "
"greater than one."
msgstr ""
"No puedes desactivar esta opción si tienes registros con más de un asistente "
"en alguno de los registros."

#~ msgid "Attendee"
#~ msgstr "Registro"
47 changes: 47 additions & 0 deletions event_registration_multi_qty/i18n/event_registration_multi_qty.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * event_registration_multi_qty
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.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_registration_multi_qty
#: model:ir.model.fields,field_description:event_registration_multi_qty.field_event_event__registration_multi_qty
msgid "Allow multiple attendees per registration"
msgstr ""

#. module: event_registration_multi_qty
#: model:ir.model,name:event_registration_multi_qty.model_event_event
msgid "Event"
msgstr ""

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

#. module: event_registration_multi_qty
#: model:ir.model.fields,field_description:event_registration_multi_qty.field_event_registration__qty
msgid "Quantity"
msgstr ""

#. module: event_registration_multi_qty
#: code:addons/event_registration_multi_qty/models/event.py:77
#, python-format
msgid "You can not add quantities if you not active the option \"Allow multiple attendees per registration\" in event"
msgstr ""

#. module: event_registration_multi_qty
#: code:addons/event_registration_multi_qty/models/event.py:57
#, python-format
msgid "You can not disable this option if there are registrations with quantities greater than one."
msgstr ""

1 change: 1 addition & 0 deletions event_registration_multi_qty/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import event
94 changes: 94 additions & 0 deletions event_registration_multi_qty/models/event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright 2017 Tecnativa - Sergio Teruel
# Copyright 2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


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

registration_multi_qty = fields.Boolean(
string="Allow multiple attendees per registration", default=True,
)

@api.depends("seats_max", "registration_ids.state", "registration_ids.qty")
def _compute_seats(self):
multi_qty_events = self.filtered("registration_multi_qty")
for event in multi_qty_events:
vals = {
"seats_unconfirmed": 0,
"seats_reserved": 0,
"seats_used": 0,
"seats_available": 0,
}
registrations = self.env["event.registration"].read_group(
[
("event_id", "=", event.id),
("state", "in", ["draft", "open", "done"]),
],
["state", "qty"],
["state"],
)
for registration in registrations:
if registration["state"] == "draft":
vals["seats_unconfirmed"] += registration["qty"]
elif registration["state"] == "open":
vals["seats_reserved"] += registration["qty"]
elif registration["state"] == "done":
vals["seats_used"] += registration["qty"]
if event.seats_max > 0:
vals["seats_available"] = event.seats_max - (
vals["seats_reserved"] + vals["seats_used"]
)
vals["seats_expected"] = (
vals["seats_unconfirmed"] + vals["seats_reserved"] + vals["seats_used"]
)
event.update(vals)
rest = self - multi_qty_events
super(EventEvent, rest)._compute_seats()

@api.constrains("registration_multi_qty")
def _check_attendees_qty(self):
for event in self:
if (
not event.registration_multi_qty
and max(event.registration_ids.mapped("qty") or [0]) > 1
):
raise ValidationError(
_(
"You can not disable this option if there are "
"registrations with quantities greater than one."
)
)


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

qty = fields.Integer(string="Quantity", required=True, default=1,)

@api.constrains("qty")
def _check_attendees_qty(self):
for registration in self:
if (
not registration.event_id.registration_multi_qty
and registration.qty > 1
):
raise ValidationError(
_(
"You can not add quantities if you not active the"
' option "Allow multiple attendees per registration"'
" in event"
)
)

@api.model
def _prepare_attendee_values(self, registration):
res = super()._prepare_attendee_values(registration)
# Passed fields are not taken into account if a default is set,
# so we need to force this
if "qty" in registration:
res.update({"qty": registration.get("qty")})
return res
5 changes: 5 additions & 0 deletions event_registration_multi_qty/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To configure the possibility of registering mutiple attendees:

#. Go to *Events > Events*.
#. Create one event.
#. Check "Allow multiple attendees per registration" to activate this function.
6 changes: 6 additions & 0 deletions event_registration_multi_qty/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* `Tecnativa <https://www.tecnativa.com>`__:

* Sergio Teruel
* Pedro M. Baeza
* David Vidal
* Carlos Roca
4 changes: 4 additions & 0 deletions event_registration_multi_qty/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module allows to make registration to events with more than one attendee.

This was the unique behavior on versions 8 and 9. As it's useful for some use
cases, this module allows both ways of registering attendees.
4 changes: 4 additions & 0 deletions event_registration_multi_qty/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
For registering multiple attendees:

#. Create an attendee for the created event.
#. Write the quantities for this registration.
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 0a49511

Please sign in to comment.