Skip to content

Commit

Permalink
Merge d0a8f89 into f180697
Browse files Browse the repository at this point in the history
  • Loading branch information
chienandalu committed May 15, 2019
2 parents f180697 + d0a8f89 commit 421f2e1
Show file tree
Hide file tree
Showing 11 changed files with 682 additions and 0 deletions.
83 changes: 83 additions & 0 deletions event_session_registration_multi_qty/README.rst
@@ -0,0 +1,83 @@
============================
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/12.0/event_session_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-12-0/event-12-0-event_session_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/12.0
:alt: Try me on Runbot

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

This module allows to make registration to sessions with multiple attendees.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

#. Go to a session registration
#. Enter the quantity of efective attendees for the record.

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_session_registration_multi_qty%0Aversion:%2012.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>`__:

* 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/12.0/event_session_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_session_registration_multi_qty/__init__.py
@@ -0,0 +1,2 @@
from . import models
from . import tests
18 changes: 18 additions & 0 deletions event_session_registration_multi_qty/__manifest__.py
@@ -0,0 +1,18 @@
# Copyright 2017-19 Tecnativa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).
{
'name': 'Event Registration Multi Qty',
'version': '12.0.1.0.0',
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
"license": "AGPL-3",
'website': 'https://www.github.com/OCA/event',
'category': 'Marketing',
'summary': 'Allow registration grouped by quantities in sessions',
'depends': [
'event_session',
'event_registration_multi_qty',
],
'installable': True,
'auto_install': True,
}
1 change: 1 addition & 0 deletions event_session_registration_multi_qty/models/__init__.py
@@ -0,0 +1 @@
from . import event_session
42 changes: 42 additions & 0 deletions event_session_registration_multi_qty/models/event_session.py
@@ -0,0 +1,42 @@
# Copyright 2017-19 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).
from odoo import api, models


class EventSession(models.Model):
_inherit = 'event.session'

@api.multi
@api.depends('seats_max', 'registration_ids.state',
'registration_ids.qty')
def _compute_seats(self):
for session in self:
if not session.event_id.registration_multi_qty:
return super(EventSession, self)._compute_seats()
vals = {
'seats_unconfirmed': 0,
'seats_reserved': 0,
'seats_used': 0,
'seats_available': 0,
'seats_available_expected': 0,
}
registrations = self.env['event.registration'].read_group([
('session_id', '=', session.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']
vals['seats_expected'] = (
vals['seats_unconfirmed'] + vals['seats_reserved'] +
vals['seats_used'])
if session.seats_max > 0:
vals['seats_available'] = session.seats_max - (
vals['seats_reserved'] + vals['seats_used'])
vals['seats_available_expected'] = (
session.seats_max - vals['seats_expected'])
session.update(vals)
3 changes: 3 additions & 0 deletions event_session_registration_multi_qty/readme/CONTRIBUTORS.rst
@@ -0,0 +1,3 @@
* `Tecnativa <https://www.tecnativa.com>`__:

* David Vidal
@@ -0,0 +1 @@
This module allows to make registration to sessions with multiple attendees.
4 changes: 4 additions & 0 deletions event_session_registration_multi_qty/readme/USAGE.rst
@@ -0,0 +1,4 @@
To use this module, you need to:

#. Go to a session registration
#. Enter the quantity of efective attendees for the record.

0 comments on commit 421f2e1

Please sign in to comment.