Skip to content

Commit

Permalink
[FIX] event_registration_multi_qty: Needed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobaeza authored and yajo committed Jun 22, 2017
1 parent 689738b commit 9edaee8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
24 changes: 14 additions & 10 deletions event_registration_multi_qty/README.rst
Expand Up @@ -8,29 +8,32 @@ Event Registration Multi Qty

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.


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

.. figure:: path/to/local/image.png
:alt: alternative description
:width: 600 px
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
=====

To use this module, you need to:
For registering multiple attendees:

#. Go to *Events* and create one.
#. Go to *Registration tab* and check "Registration Multi Qty" to activate
this function.
#. Create an attendee for this event and you can write the quantities for this
this registration.
#. Create an attendee for the created event.
#. Write the quantities for this registration.


.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/199/10
:target: https://runbot.odoo-community.org/runbot/199/10.0


Bug Tracker
Expand All @@ -53,6 +56,7 @@ Contributors
------------

* Sergio Teruel <sergio.teruel@tecnativa.com>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>


Maintainer
Expand Down
2 changes: 1 addition & 1 deletion event_registration_multi_qty/i18n/es.po
Expand Up @@ -52,7 +52,7 @@ msgstr ""
#, python-format
msgid ""
"You can not disable this option if there are registrations with quantities "
"grather than one."
"greater than one."
msgstr ""
"No puedes desactivar esta opción si tienes registros con más de un "
"asistente en alguno de los registros."
Expand Down
12 changes: 7 additions & 5 deletions event_registration_multi_qty/models/event.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Sergio Teruel<sergio.teruel@tecnativa.com>
# 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
Expand All @@ -18,9 +19,8 @@ class EventEvent(models.Model):
@api.depends('seats_max', 'registration_ids.state',
'registration_ids.qty')
def _compute_seats(self):
for event in self:
if not event.registration_multi_qty:
return super(EventEvent, self)._compute_seats()
multi_qty_events = self.filtered('registration_multi_qty')
for event in multi_qty_events:
vals = {
'seats_unconfirmed': 0,
'seats_reserved': 0,
Expand All @@ -45,6 +45,8 @@ def _compute_seats(self):
vals['seats_unconfirmed'] + vals['seats_reserved'] +
vals['seats_used'])
event.update(vals)
rest = self - multi_qty_events
super(EventEvent, rest)._compute_seats()

@api.multi
@api.constrains('registration_multi_qty')
Expand All @@ -54,7 +56,7 @@ def _check_attendees_qty(self):
max(event.registration_ids.mapped('qty') or [0]) > 1:
raise ValidationError(
_('You can not disable this option if there are '
'registrations with quantities grather than one.'))
'registrations with quantities greater than one.'))


class EventRegistration(models.Model):
Expand Down
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Sergio Teruel <sergio.teruel@tecnativa.com>
# Copyright 2017 Tecnativa - Sergio Teruel
# Copyright 2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models
Expand All @@ -9,9 +10,7 @@ class ReportEventRegistration(models.Model):
"""Events Analysis"""
_inherit = "report.event.registration"

def _sub_select(self):
def _select(self):
"""Replace the SQL expression that gets the number of registrations."""
select_str = super(ReportEventRegistration, self)._sub_select()
select_str = select_str.replace('count(r.event_id)', 'sum(qty)')
select_str = select_str.replace('count(r.id)', 'sum(qty)')
return select_str
select_str = super(ReportEventRegistration, self)._select()
return select_str.replace('count(r.event_id)', 'sum(r.qty)')

0 comments on commit 9edaee8

Please sign in to comment.