-
-
-
- Ticket Type #: (
-
-
-
-
- Free)
-
-
-
+
Name
Phone (Optional)
Email (Optional)
-
+
-
diff --git a/addons/website_event_questions/__init__.py b/addons/website_event_questions/__init__.py
new file mode 100644
index 00000000000..455ae859a94
--- /dev/null
+++ b/addons/website_event_questions/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2015-TODAY Odoo S.A. ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import controllers
+import models
+import report
diff --git a/addons/website_event_questions/__openerp__.py b/addons/website_event_questions/__openerp__.py
new file mode 100644
index 00000000000..24025e15b62
--- /dev/null
+++ b/addons/website_event_questions/__openerp__.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+
+{
+ 'name': 'Questions on Events',
+ 'description': 'Questions on Events',
+ 'category': 'Website',
+ 'version': '1.0',
+ 'author': 'Odoo S.A.',
+ 'depends': ['website_event'],
+ 'data': [
+ 'views/website_event_questions_backend.xml',
+ 'views/website_event_questions_templates.xml',
+ 'report/report_event_question_view.xml',
+ 'security/ir.model.access.csv',
+ ],
+ 'demo': [
+ 'data/demo.xml',
+ ],
+ 'installable': True,
+}
diff --git a/addons/website_event_questions/controllers/__init__.py b/addons/website_event_questions/controllers/__init__.py
new file mode 100644
index 00000000000..bbd183e955b
--- /dev/null
+++ b/addons/website_event_questions/controllers/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+import main
diff --git a/addons/website_event_questions/controllers/main.py b/addons/website_event_questions/controllers/main.py
new file mode 100644
index 00000000000..7d78d7fa11e
--- /dev/null
+++ b/addons/website_event_questions/controllers/main.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+
+from openerp.addons.website_event.controllers.main import website_event
+
+
+class website_event(website_event):
+
+ def _process_registration_details(self, details):
+ ''' Process data posted from the attendee details form. '''
+ registrations = super(website_event, self)._process_registration_details(details)
+ for registration in registrations:
+ answer_ids = []
+ for key, value in registration.iteritems():
+ if key.startswith('answer_ids-'):
+ answer_ids.append([4, int(value)])
+ registration['answer_ids'] = answer_ids
+ return registrations
diff --git a/addons/website_event_questions/data/demo.xml b/addons/website_event_questions/data/demo.xml
new file mode 100644
index 00000000000..e413de1ae85
--- /dev/null
+++ b/addons/website_event_questions/data/demo.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+ Kind of partner
+
+ 1
+
+
+ Veggie
+
+ 2
+
+
+
+ Accommodation
+
+ 3
+
+
+
+ Gold
+
+ 3
+
+
+ Silver
+
+ 2
+
+
+ Bronze
+
+ 1
+
+
+
+ Yes
+
+ 2
+
+
+ No
+
+ 1
+
+
+
+ Personal
+
+ 1
+
+
+ In Charge
+
+ 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/website_event_questions/models/__init__.py b/addons/website_event_questions/models/__init__.py
new file mode 100644
index 00000000000..80f7716c2e1
--- /dev/null
+++ b/addons/website_event_questions/models/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+import event
diff --git a/addons/website_event_questions/models/event.py b/addons/website_event_questions/models/event.py
new file mode 100644
index 00000000000..3d9165357b7
--- /dev/null
+++ b/addons/website_event_questions/models/event.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+
+from openerp import models, fields
+
+
+class EventEvent(models.Model):
+ """ Override Event model to add optional questions when buying tickets. """
+ _inherit = 'event.event'
+
+ question_ids = fields.One2many('event.question', 'event_id', 'Questions')
+ general_question_ids = fields.One2many('event.question', 'event_id', 'Questions',
+ domain=[('is_individual', '=', False)])
+ specific_question_ids = fields.One2many('event.question', 'event_id', 'Questions',
+ domain=[('is_individual', '=', True)])
+
+
+class EventRegistrationAnswer(models.Model):
+ ''' This m2m table has to be explicitly instanciated as we need unique ids
+ in the reporting view event.question.report.
+
+ This model is purely technical. '''
+
+ _name = 'event.registration.answer'
+ _table = 'event_registration_answer'
+
+ event_answer_id = fields.Many2one('event.answer', required=True)
+ event_registration_id = fields.Many2one('event.registration', required=True)
+
+
+class EventRegistration(models.Model):
+ """ Store answers on attendees. """
+ _inherit = 'event.registration'
+
+ answer_ids = fields.Many2many('event.answer', 'event_registration_answer', string='Answers')
+
+
+class EventQuestion(models.Model):
+ _name = 'event.question'
+ _rec_name = 'title'
+ _order = 'sequence,id'
+
+ title = fields.Char(required=True, translate=True)
+ event_id = fields.Many2one('event.event', required=True, ondelete='cascade')
+ answer_ids = fields.One2many('event.answer', 'question_id', "Answers", required=True)
+ sequence = fields.Integer(default=10)
+ is_individual = fields.Boolean('Ask each attendee',
+ help="If True, this question will be asked for every attendee of a reservation. If "
+ "not it will be asked only once and its value propagated to every attendees.")
+
+
+class EventAnswer(models.Model):
+ _name = 'event.answer'
+ _order = 'sequence,id'
+
+ name = fields.Char('Answer', required=True, translate=True)
+ question_id = fields.Many2one('event.question', required=True, ondelete='cascade')
+ sequence = fields.Integer(default=10)
diff --git a/addons/website_event_questions/report/__init__.py b/addons/website_event_questions/report/__init__.py
new file mode 100644
index 00000000000..5e33c199720
--- /dev/null
+++ b/addons/website_event_questions/report/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+import report_event_registrations_questions
diff --git a/addons/website_event_questions/report/report_event_question_view.xml b/addons/website_event_questions/report/report_event_question_view.xml
new file mode 100644
index 00000000000..4f98b33fc9e
--- /dev/null
+++ b/addons/website_event_questions/report/report_event_question_view.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+ event.question.report.graph
+ event.question.report
+
+
+
+
+
+
+
+
+
+
+ event.question.report.pivot
+ event.question.report
+
+
+
+
+
+
+
+
+
+
+
+
+ event.question.report.search
+ event.question.report
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Questions Analysis
+ event.question.report
+ form
+ pivot,graph
+
+
+
+
+
+
+
diff --git a/addons/website_event_questions/report/report_event_registrations_questions.py b/addons/website_event_questions/report/report_event_registrations_questions.py
new file mode 100644
index 00000000000..0e4f949ca97
--- /dev/null
+++ b/addons/website_event_questions/report/report_event_registrations_questions.py
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+
+from openerp import fields, models, tools
+
+
+class ReportEventRegistrationQuestions(models.Model):
+ _name = "event.question.report"
+ _auto = False
+
+ attendee_id = fields.Many2one(comodel_name='event.registration', string='Registration')
+ question_id = fields.Many2one(comodel_name='event.question', string='Question')
+ answer_id = fields.Many2one(comodel_name='event.answer', string='Answer')
+ event_id = fields.Many2one(comodel_name='event.event', string='Event')
+
+ def init(self, cr):
+ """ Event Question main report """
+ tools.drop_view_if_exists(cr, 'event_question_report')
+ cr.execute(""" CREATE VIEW event_question_report AS (
+ SELECT
+ att_answer.id as id,
+ att_answer.event_registration_id as attendee_id,
+ answer.question_id as question_id,
+ answer.id as answer_id,
+ question.event_id as event_id
+ FROM
+ event_registration_answer as att_answer
+ LEFT JOIN
+ event_answer as answer ON answer.id = att_answer.event_answer_id
+ LEFT JOIN
+ event_question as question ON question.id = answer.question_id
+ GROUP BY
+ attendee_id,
+ event_id,
+ question_id,
+ answer_id,
+ att_answer.id
+ )""")
diff --git a/addons/website_event_questions/security/ir.model.access.csv b/addons/website_event_questions/security/ir.model.access.csv
new file mode 100644
index 00000000000..79ab8690426
--- /dev/null
+++ b/addons/website_event_questions/security/ir.model.access.csv
@@ -0,0 +1,7 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+event_question_all,event.question.all,model_event_question,,1,0,0,0
+event_question_event_user,event.question.event.user,model_event_question,event.group_event_user,1,1,1,1
+event_answer_all,event.answer.all,model_event_answer,,1,0,0,0
+event_answer_event_user,event.answer.event.user,model_event_answer,event.group_event_user,1,1,1,1
+event_question_report_all,event.question.report.all,model_event_question_report,event.group_event_user,1,1,1,1
+event_registration_answer_all,access_event_registration_answer,model_event_registration_answer,,1,1,1,1
diff --git a/addons/website_event_questions/views/website_event_questions_backend.xml b/addons/website_event_questions/views/website_event_questions_backend.xml
new file mode 100644
index 00000000000..a4428bd8094
--- /dev/null
+++ b/addons/website_event_questions/views/website_event_questions_backend.xml
@@ -0,0 +1,78 @@
+
+
+
+
+ event.question.form
+ event.question
+
+
+
+
+
+
+ event.answer.simplified.form
+ event.answer
+
+
+
+
+
+
+ event.form.inherit.question
+ event.event
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ event.registration.form.inherit.question
+ event.registration
+
+
+
+
+
+
+
+
+
+ event.registration.search.inherit.question
+ event.registration
+
+
+
+
+
+
+
+
+
diff --git a/addons/website_event_questions/views/website_event_questions_templates.xml b/addons/website_event_questions/views/website_event_questions_templates.xml
new file mode 100644
index 00000000000..ec9c055e2ae
--- /dev/null
+++ b/addons/website_event_questions/views/website_event_questions_templates.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+