Skip to content

Commit

Permalink
[12.0] event_sale_session: Migration to 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chienandalu committed May 15, 2019
1 parent 0d2018a commit cee87f4
Show file tree
Hide file tree
Showing 21 changed files with 604 additions and 60 deletions.
79 changes: 63 additions & 16 deletions event_sale_session/README.rst
@@ -1,39 +1,86 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
===================
Event Sale Sessions
===================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Sell tickets associated to sessions
===================================
.. |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_sale_session
: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_sale_session
: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

Adds the option of choosing a session when selling an event ticket
|badge1| |badge2| |badge3| |badge4| |badge5|

Adds the option of choosing a session when selling an event ticket.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

#. Place a sale order and choose an event registration product.
#. If the event has sessions, you'll be compelled to choose one.
#. The registration will be added to such session once the sale order is
confirmed.

Known issues / Roadmap
======================
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_sale_session%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
------------
~~~~~~~~~~~~

* Sergio Teruel <sergio.teruel@tecnativa.com>
* David Vidal <david.vidal@tecnativa.com>
* `Tecnativa <https://www.tecnativa.com>`__:

Maintainer
----------
* Sergio Teruel
* 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

This module is maintained by the OCA.

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.
promote its widespread use.

This module is part of the `OCA/event <https://github.com/OCA/event/tree/12.0/event_sale_session>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 1 addition & 2 deletions event_sale_session/__init__.py
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

from . import models
from . import reports
from . import wizard
11 changes: 5 additions & 6 deletions event_sale_session/__manifest__.py
@@ -1,22 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2017 David Vidal<david.vidal@tecnativa.com>
# Copyright 2017-19 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Event Sale Sessions',
'version': '10.0.1.0.0',
'summary': 'Sessions sales in events',
'version': '12.0.1.0.0',
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
"license": "AGPL-3",
'website': 'https://odoo-community.org/',
'website': 'https://github.com/OCA/event',
'category': 'Marketing',
'summary': 'Sessions sales in events',
'depends': [
'event_sale',
'event_session',
],
'data': [
'security/ir.model.access.csv',
'reports/sale_report_views.xml',
'views/sale_order_views.xml',
'views/event_view.xml',
'views/event_session_view.xml',
Expand Down
2 changes: 0 additions & 2 deletions event_sale_session/models/__init__.py
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from . import account_invoice
from . import event_event
from . import event_registration
Expand Down
6 changes: 2 additions & 4 deletions event_sale_session/models/account_invoice.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Sergio Teruel<sergio.teruel@tecnativa.com>
# Copyright 2017 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models


Expand All @@ -17,7 +15,7 @@ def action_cancel(self):
lambda x: x.state not in ['done', 'draft']
).do_draft()
return res

@api.multi
def unlink(self):
registrations = self.mapped(
Expand Down
11 changes: 5 additions & 6 deletions event_sale_session/models/event_event.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

# Copyright 2017-19 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models


Expand Down Expand Up @@ -29,10 +29,9 @@ def _compute_unconfirmed_qty(self):
@api.multi
def button_open_unconfirmed_event_order(self):
action = self.env.ref('sale.action_quotations').read()[0]
sales = self.env[
'sale.order.line'].search(
[('event_id','=',self.id)]).mapped('order_id').ids
sales = self.env['sale.order.line'].search([
('event_id', 'in', self.ids)]).mapped('order_id').ids
action['domain'] = [('id', 'in' , sales),
('state','in',('draft','sent'))]
('state', 'in', ('draft', 'sent'))]
action['context'] = {}
return action
4 changes: 1 addition & 3 deletions event_sale_session/models/event_registration.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2017 David Vidal<david.vidal@tecnativa.com>
# Copyright 2017-19 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models


Expand Down
4 changes: 2 additions & 2 deletions event_sale_session/models/event_session.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

# Copyright 2017-19 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models


Expand Down
9 changes: 5 additions & 4 deletions event_sale_session/models/sale_order.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

# Copyright 2017-19 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo import exceptions

Expand All @@ -26,6 +26,7 @@ def _compute_event_ids(self):
for sale in self:
sale.event_ids = sale.order_line.mapped('event_id')


class SaleOrderLine(models.Model):

_inherit = 'sale.order.line'
Expand Down Expand Up @@ -79,8 +80,8 @@ def product_uom_change(self):
def event_id_change(self):
for so_line in self:
so_line.name = so_line._set_order_line_description()
if self.event_sessions_count == 1:
so_line.session_id = self.event_id.session_ids[0]
if so_line.event_sessions_count == 1:
so_line.session_id = so_line.event_id.session_ids[0]

def _session_seats_available(self):
self.ensure_one()
Expand Down
4 changes: 4 additions & 0 deletions event_sale_session/readme/CONTRIBUTORS.rst
@@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`__:

* Sergio Teruel
* David Vidal
1 change: 1 addition & 0 deletions event_sale_session/readme/DESCRIPTION.rst
@@ -0,0 +1 @@
Adds the option of choosing a session when selling an event ticket.
6 changes: 6 additions & 0 deletions event_sale_session/readme/USAGE.rst
@@ -0,0 +1,6 @@
To use this module, you need to:

#. Place a sale order and choose an event registration product.
#. If the event has sessions, you'll be compelled to choose one.
#. The registration will be added to such session once the sale order is
confirmed.
1 change: 1 addition & 0 deletions event_sale_session/reports/__init__.py
@@ -0,0 +1 @@
from . import sale_report
38 changes: 38 additions & 0 deletions event_sale_session/reports/sale_report.py
@@ -0,0 +1,38 @@
# Copyright 2017 Sergio Teruel <sergio.teruel@tecnativa.com>
# Copyright 2019 David Vidal <david.vidal@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields


class SaleReport(models.Model):
_inherit = "sale.report"

event_id = fields.Many2one(
comodel_name='event.event',
string='Event',
readonly=True,
)
session_id = fields.Many2one(
comodel_name='event.session',
string='Session',
readonly=True,
)
event_session_count = fields.Integer(
string='Number of event sessions', readonly=True, group_operator="avg")

def _query(self, with_clause='', fields=None, groupby='', from_clause=''):
fields = dict(fields or {})
fields.update({
'event_id': ' ,min(l.event_id) as event_id',
'session_id': ' ,min(l.session_id) as session_id',
'event_session_count':
', min(ev.sessions_count) as event_session_count',
})
from_clause += """
LEFT JOIN event_session es ON l.session_id = es.id
LEFT JOIN event_event ev ON l.event_id = ev.id
"""
groupby += """
,l.event_id, l.session_id, l.id
"""
return super()._query(with_clause, fields, groupby, from_clause)
28 changes: 28 additions & 0 deletions event_sale_session/reports/sale_report_views.xml
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<!-- Copyright 2017 Sergio Teruel <sergio.teruel@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

<record id="view_order_product_pivot" model="ir.ui.view">
<field name="model">sale.report</field>
<field name="inherit_id" ref="sale.view_order_product_pivot"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='confirmation_date']" position="after">
<field name="event_id" type="row"/>
<field name="session_id" type="row"/>
</xpath>
</field>
</record>

<record id="view_order_product_search" model="ir.ui.view">
<field name="model">sale.report</field>
<field name="inherit_id" ref="sale.view_order_product_search"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='product_id']" position="after">
<field name="event_id"/>
<field name="session_id"/>
</xpath>
</field>
</record>

</odoo>

0 comments on commit cee87f4

Please sign in to comment.