Skip to content

Commit

Permalink
Merge 7082f41 into 546c8fc
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobaeza committed Feb 14, 2016
2 parents 546c8fc + 7082f41 commit cd2d1e9
Show file tree
Hide file tree
Showing 14 changed files with 430 additions and 0 deletions.
70 changes: 70 additions & 0 deletions event_registration_cancel_reason/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.. 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

=============================================
Reasons for event registrations cancellations
=============================================

This module allows to add a predefined reason why a registration for an event
is cancelled.

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

Go to *Marketing > Configuration > Events > Registrations cancel reasons* for
setting the possible reasons you want to handle. You can also set if a reason
is only available for certain types of events or, if you leave it empty, for
all.

Usage
=====

Go to *Marketing > Events > Events*, enter into the details of any of the
events, and press the red circle button in the right part of any of the
registrations. A new screen will appear asking you to enter the reason why the
registration is cancelled.

You will get also the same screen when pressing the button
*Cancel registration* from the details view of a registration in
*Marketing > Events > Registrations*. On this object, you can group by the
cancel reason in the list, calendar or graph view.

.. 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/8.0

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:%20
event_registration_cancel_reason%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Contributors
------------

* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>

Maintainer
----------

.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://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.

To contribute to this module, please visit http://odoo-community.org.
7 changes: 7 additions & 0 deletions event_registration_cancel_reason/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import models
from . import wizard
24 changes: 24 additions & 0 deletions event_registration_cancel_reason/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

{
"name": "Reasons for event registrations cancellations",
"version": "8.0.1.0.0",
"license": "AGPL-3",
"author": "Antiun Ingeniería S.L., "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Odoo Community Association (OCA)",
"website": "https://www.antiun.com",
"category": "Event Management",
"depends": [
'event',
],
"data": [
'security/ir.model.access.csv',
'views/event_registration_view.xml',
'wizard/event_registration_cancel_log_reason_view.xml',
],
"installable": True,
}
113 changes: 113 additions & 0 deletions event_registration_cancel_reason/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * event_registration_cancel_reason
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-02-03 07:55+0000\n"
"PO-Revision-Date: 2016-02-03 07:55+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_registration_cancel_reason
#: view:event.registration.cancel.log.reason:event_registration_cancel_reason.event_registration_cancel_log_reason_view
msgid "Abort"
msgstr "Abortar"

#. module: event_registration_cancel_reason
#: field:event.registration.cancel.reason,event__type_ids:0
msgid "Event type"
msgstr "Tipos de evento"

#. module: event_registration_cancel_reason
#: view:event.registration:event_registration_cancel_reason.view_registration_search
msgid "Cancel reason"
msgstr "Razón de cancelación"

#. module: event_registration_cancel_reason
#: view:event.registration.cancel.log.reason:event_registration_cancel_reason.event_registration_cancel_log_reason_view
msgid "Cancel registration"
msgstr "Cancelar registro"

#. module: event_registration_cancel_reason
#: field:event.registration.cancel.log.reason,create_uid:0
#: field:event.registration.cancel.reason,create_uid:0
msgid "Created by"
msgstr "Creado por"

#. module: event_registration_cancel_reason
#: field:event.registration.cancel.log.reason,create_date:0
#: field:event.registration.cancel.reason,create_date:0
msgid "Created on"
msgstr "Creado en"

#. module: event_registration_cancel_reason
#: field:event.registration.cancel.log.reason,event_type_id:0
msgid "Event type"
msgstr "Tipo de evento"

#. module: event_registration_cancel_reason
#: model:ir.model,name:event_registration_cancel_reason.model_event_registration
msgid "Event Registration"
msgstr "Registro evento"

#. module: event_registration_cancel_reason
#: field:event.registration.cancel.log.reason,id:0
#: field:event.registration.cancel.reason,id:0
msgid "ID"
msgstr "ID"

#. module: event_registration_cancel_reason
#: field:event.registration.cancel.log.reason,write_uid:0
#: field:event.registration.cancel.reason,write_uid:0
msgid "Last Updated by"
msgstr "Última actualización por"

#. module: event_registration_cancel_reason
#: field:event.registration.cancel.log.reason,write_date:0
#: field:event.registration.cancel.reason,write_date:0
msgid "Last Updated on"
msgstr "Última actualización en"

#. module: event_registration_cancel_reason
#: field:event.registration.cancel.reason,name:0
msgid "Reason"
msgstr "Razón"

#. module: event_registration_cancel_reason
#: field:event.registration,cancel_reason_id:0
msgid "Cancellation reason"
msgstr "Razón para la cancelación"

#. module: event_registration_cancel_reason
#: field:event.registration.cancel.log.reason,reason_id:0
msgid "Reason id"
msgstr "Razón"

#. module: event_registration_cancel_reason
#: model:ir.actions.act_window,name:event_registration_cancel_reason.event_registration_cancel_reason_action
#: model:ir.ui.menu,name:event_registration_cancel_reason.menu_event_registration_cancel_reason
msgid "Registrations cancel reasons"
msgstr "Razones de cancelación de registros"

#. module: event_registration_cancel_reason
#: help:event.registration.cancel.reason,event_type_ids:0
msgid "Select the event types where you want to use this cancellation reason. Leave it empty for using in all"
msgstr "Seleccione los tipos de evento en los que quiere usar esta razón de cancelación. Déjelo en blanco para usarla en todos."

#. module: event_registration_cancel_reason
#: view:event.registration.cancel.log.reason:event_registration_cancel_reason.event_registration_cancel_log_reason_view
msgid "Select the reason for cancelling the registration:"
msgstr "Seleccione la razón para cancelar el registro:"

#. module: event_registration_cancel_reason
#: view:event.registration.cancel.log.reason:event_registration_cancel_reason.event_registration_cancel_log_reason_view
msgid "or"
msgstr "o"

6 changes: 6 additions & 0 deletions event_registration_cancel_reason/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import event_registration
42 changes: 42 additions & 0 deletions event_registration_cancel_reason/models/event_registration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from openerp import api, fields, models


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

cancel_reason_id = fields.Many2one(
comodel_name='event.registration.cancel.reason', readonly=True,
string="Cancellation reason", ondelete="restrict")

@api.multi
def button_reg_cancel(self):
if self.env.context.get('bypass_reason'):
return super(EventRegistration, self).button_reg_cancel()
return {
'type': 'ir.actions.act_window',
'name': 'Cancel reason',
'res_model': 'event.registration.cancel.log.reason',
'view_type': 'form',
'view_mode': 'form',
'target': 'new',
}

@api.multi
def do_draft(self):
super(EventRegistration, self).do_draft()
self.write({'cancel_reason_id': False})


class EventRegistrationCancelReason(models.Model):
_name = 'event.registration.cancel.reason'

name = fields.Char('Reason', required=True, translate=True)
event_type_ids = fields.Many2many(
comodel_name="event.type", string="Event types",
help="Select the event types where you want to use this cancellation "
"reason. Leave it empty for using in all")
2 changes: 2 additions & 0 deletions event_registration_cancel_reason/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_event_registration_cancel_reason,event.registration.cancel.reason,model_event_registration_cancel_reason,event.group_event_user,1,1,1,1
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions event_registration_cancel_reason/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import test_event_registration_cancel_reason
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from openerp import fields
from openerp.tests import common


class TestEventRegistrationCancelReason(common.TransactionCase):
def setUp(self):
super(TestEventRegistrationCancelReason, self).setUp()
self.event = self.env['event.event'].create(
{'name': 'Test event',
'date_begin': fields.Date.today(),
'date_end': fields.Date.today()})
self.partner = self.env['res.partner'].create({'name': 'Test partner'})
self.cancel_reason = self.env[
'event.registration.cancel.reason'].create({'name': 'Test reason'})
self.registration = self.env['event.registration'].create(
{'event_id': self.event.id,
'partner_id': self.partner.id})

def test_cancel(self):
action = self.registration.button_reg_cancel()
self.assertEqual(action.get('type'), 'ir.actions.act_window')
wizard_model = self.env['event.registration.cancel.log.reason']
wizard = wizard_model.with_context(
active_id=self.registration.id).create(
{'reason_id': self.cancel_reason.id})
wizard.button_log()
self.assertEqual(
self.registration.cancel_reason_id, self.cancel_reason)
56 changes: 56 additions & 0 deletions event_registration_cancel_reason/views/event_registration_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>

<record model="ir.ui.view" id="view_event_registration_form">
<field name="name">Event registration form (with cancel reason)</field>
<field name="model">event.registration</field>
<field name="inherit_id" ref="event.view_event_registration_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//sheet/h1" position="after">
<h2 attrs="{'invisible':[('cancel_reason_id','=',False)]}">
<label for="cancel_reason_id" string="Cancel Reason:"/>
<field name="cancel_reason_id" class="oe_inline" options="{'no_open':True'}"/>
</h2>
</xpath>
</data>
</field>
</record>

<record model="ir.ui.view" id="view_registration_search">
<field name="name">Event registration search (with cancel reason)</field>
<field name="model">event.registration</field>
<field name="inherit_id" ref="event.view_registration_search"/>
<field name="arch" type="xml">
<filter context="{'group_by':'state'}" position="after">
<filter string="Cancel reason" domain="[]" context="{'group_by': 'cancel_reason_id'}"/>
</filter>
</field>
</record>

<record model="ir.ui.view" id="event_registration_cancel_reason_tree">
<field name="name">Registrations cancel reasons tree</field>
<field name="model">event.registration.cancel.reason</field>
<field name="arch" type="xml">
<tree name="Registrations cancel reasons" editable="top">
<field name="name"/>
<field name="event_type_ids" widget="many2many_tags"/>
</tree>
</field>
</record>

<record id="event_registration_cancel_reason_action" model="ir.actions.act_window">
<field name="name">Registrations cancel reasons</field>
<field name="res_model">event.registration.cancel.reason</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>

<menuitem action="event_registration_cancel_reason_action"
id="menu_event_registration_cancel_reason"
parent="event.event_configuration"
/>

</data>
</openerp>
6 changes: 6 additions & 0 deletions event_registration_cancel_reason/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import event_registration_cancel_log_reason

0 comments on commit cd2d1e9

Please sign in to comment.