diff --git a/event_registration_cancel_reason/README.rst b/event_registration_cancel_reason/README.rst new file mode 100644 index 000000000..48efe23bd --- /dev/null +++ b/event_registration_cancel_reason/README.rst @@ -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 +`_. 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 +`_. + +Credits +======= + +Contributors +------------ + +* Pedro M. Baeza + +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. diff --git a/event_registration_cancel_reason/__init__.py b/event_registration_cancel_reason/__init__.py new file mode 100644 index 000000000..62a7dd3b7 --- /dev/null +++ b/event_registration_cancel_reason/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import models +from . import wizard diff --git a/event_registration_cancel_reason/__openerp__.py b/event_registration_cancel_reason/__openerp__.py new file mode 100644 index 000000000..4b7e1ff5e --- /dev/null +++ b/event_registration_cancel_reason/__openerp__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# 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, +} diff --git a/event_registration_cancel_reason/i18n/es.po b/event_registration_cancel_reason/i18n/es.po new file mode 100644 index 000000000..02c04fc00 --- /dev/null +++ b/event_registration_cancel_reason/i18n/es.po @@ -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" + diff --git a/event_registration_cancel_reason/models/__init__.py b/event_registration_cancel_reason/models/__init__.py new file mode 100644 index 000000000..352570740 --- /dev/null +++ b/event_registration_cancel_reason/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import event_registration diff --git a/event_registration_cancel_reason/models/event_registration.py b/event_registration_cancel_reason/models/event_registration.py new file mode 100644 index 000000000..69d4248e6 --- /dev/null +++ b/event_registration_cancel_reason/models/event_registration.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# 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") diff --git a/event_registration_cancel_reason/security/ir.model.access.csv b/event_registration_cancel_reason/security/ir.model.access.csv new file mode 100644 index 000000000..6cc24a241 --- /dev/null +++ b/event_registration_cancel_reason/security/ir.model.access.csv @@ -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 diff --git a/event_registration_cancel_reason/static/description/icon.png b/event_registration_cancel_reason/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/event_registration_cancel_reason/static/description/icon.png differ diff --git a/event_registration_cancel_reason/tests/__init__.py b/event_registration_cancel_reason/tests/__init__.py new file mode 100644 index 000000000..68f4aa01f --- /dev/null +++ b/event_registration_cancel_reason/tests/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import test_event_registration_cancel_reason diff --git a/event_registration_cancel_reason/tests/test_event_registration_cancel_reason.py b/event_registration_cancel_reason/tests/test_event_registration_cancel_reason.py new file mode 100644 index 000000000..11faed6fe --- /dev/null +++ b/event_registration_cancel_reason/tests/test_event_registration_cancel_reason.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# 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) diff --git a/event_registration_cancel_reason/views/event_registration_view.xml b/event_registration_cancel_reason/views/event_registration_view.xml new file mode 100644 index 000000000..7296bef08 --- /dev/null +++ b/event_registration_cancel_reason/views/event_registration_view.xml @@ -0,0 +1,56 @@ + + + + + + Event registration form (with cancel reason) + event.registration + + + + +

+

+
+
+
+
+ + + Event registration search (with cancel reason) + event.registration + + + + + + + + + + Registrations cancel reasons tree + event.registration.cancel.reason + + + + + + + + + + Registrations cancel reasons + event.registration.cancel.reason + form + tree + + + + +
+
diff --git a/event_registration_cancel_reason/wizard/__init__.py b/event_registration_cancel_reason/wizard/__init__.py new file mode 100644 index 000000000..e0a58f808 --- /dev/null +++ b/event_registration_cancel_reason/wizard/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import event_registration_cancel_log_reason diff --git a/event_registration_cancel_reason/wizard/event_registration_cancel_log_reason.py b/event_registration_cancel_reason/wizard/event_registration_cancel_log_reason.py new file mode 100644 index 000000000..15bf8f28b --- /dev/null +++ b/event_registration_cancel_reason/wizard/event_registration_cancel_log_reason.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import api, fields, models + + +class EventRegistrationCancelLogReason(models.TransientModel): + _name = 'event.registration.cancel.log.reason' + + event_type_id = fields.Many2one( + comodel_name="event.type", string="Event type") + reason_id = fields.Many2one( + comodel_name="event.registration.cancel.reason", required=True, + domain="['|', " + " ('event_type_ids', '=', False), " + " ('event_type_ids', '=', event_type_id)]") + + @api.model + def default_get(self, var_fields): + res = super(EventRegistrationCancelLogReason, self).default_get( + var_fields) + registration = self.env['event.registration'].browse( + self.env.context['active_id']) + res['event_type_id'] = registration.event_id.type.id + return res + + @api.multi + def button_log(self): + self.ensure_one() + registration = self.env['event.registration'].browse( + self.env.context['active_id']) + registration.cancel_reason_id = self.reason_id.id + registration.with_context(bypass_reason=True).button_reg_cancel() diff --git a/event_registration_cancel_reason/wizard/event_registration_cancel_log_reason_view.xml b/event_registration_cancel_reason/wizard/event_registration_cancel_log_reason_view.xml new file mode 100644 index 000000000..59c6f2259 --- /dev/null +++ b/event_registration_cancel_reason/wizard/event_registration_cancel_log_reason_view.xml @@ -0,0 +1,30 @@ + + + + + + Wizard for logging registrations cancellation + event.registration.cancel.log.reason + +
+ +
+ +
+