diff --git a/addons/event/data/mail_template_data.xml b/addons/event/data/mail_template_data.xml
index e34855e198b..75235a18b76 100644
--- a/addons/event/data/mail_template_data.xml
+++ b/addons/event/data/mail_template_data.xml
@@ -11,7 +11,7 @@
Sent automatically to someone after they registered to an event
- Dear Oscar Morgan,
+ Dear ,
Thank you for your inquiry.
Here is your badge for the event OpenWood Collection Online Reveal.
If you have any questions, please let us know.
@@ -50,7 +50,7 @@
Your registration
- Oscar Morgan
+
@@ -75,7 +75,7 @@
- Hello Oscar Morgan,
+ Hello ,
We are happy to confirm your registration to the event
OpenWood Collection Online Reveal
@@ -83,7 +83,7 @@
OpenWood Collection Online Reveal
- for attendee Oscar Morgan.
+ for attendee .
@@ -282,7 +282,7 @@
Your registration
- Oscar Morgan
+
- Hello Oscar Morgan,
+ Hello ,
We are excited to remind you that the event
OpenWood Collection Online Reveal
diff --git a/addons/event/models/event_registration.py b/addons/event/models/event_registration.py
index 22043ef9c5e..15456493a58 100644
--- a/addons/event/models/event_registration.py
+++ b/addons/event/models/event_registration.py
@@ -34,6 +34,8 @@ class EventRegistration(models.Model):
email = fields.Char(string='Email', compute='_compute_email', readonly=False, store=True, tracking=11)
phone = fields.Char(string='Phone', compute='_compute_phone', readonly=False, store=True, tracking=12)
mobile = fields.Char(string='Mobile', compute='_compute_mobile', readonly=False, store=True, tracking=13)
+ company_name = fields.Char(
+ string='Company Name', compute='_compute_company_name', readonly=False, store=True, tracking=14)
# organization
date_closed = fields.Datetime(
string='Attended Date', compute='_compute_date_closed',
@@ -86,6 +88,15 @@ class EventRegistration(models.Model):
fnames=['mobile']
).get('mobile') or False
+ @api.depends('partner_id')
+ def _compute_company_name(self):
+ for registration in self:
+ if not registration.company_name and registration.partner_id:
+ registration.company_name = registration._synchronize_partner_values(
+ registration.partner_id,
+ fnames=['company_name']
+ ).get('company_name') or False
+
@api.depends('state')
def _compute_date_closed(self):
for registration in self:
diff --git a/addons/event/views/event_registration_views.xml b/addons/event/views/event_registration_views.xml
index e813c50e303..d5497e684a9 100644
--- a/addons/event/views/event_registration_views.xml
+++ b/addons/event/views/event_registration_views.xml
@@ -16,6 +16,7 @@
+
@@ -64,6 +65,7 @@
+
diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py
index 7ae4c40491e..781c02ca756 100644
--- a/addons/website_event/controllers/main.py
+++ b/addons/website_event/controllers/main.py
@@ -1,20 +1,14 @@
# -*- coding: utf-8 -*-
import babel.dates
-import pytz
import re
import werkzeug
from ast import literal_eval
-from collections import defaultdict
-from datetime import datetime, timedelta
-from dateutil.parser import parse
-from dateutil.relativedelta import relativedelta
from werkzeug.datastructures import OrderedMultiDict
from werkzeug.exceptions import NotFound
from odoo import fields, http, _
-from odoo.addons.http_routing.models.ir_http import slug
from odoo.addons.website.controllers.main import QueryURL
from odoo.http import request
from odoo.osv import expression
@@ -270,51 +264,65 @@ class WebsiteEventController(http.Controller):
if int(ticket_id) not in event.event_ticket_ids.ids and len(event.event_ticket_ids.ids) > 0:
raise UserError(_("This ticket is not available for sale for this event"))
registrations = {}
- global_values = {}
general_answer_ids = []
+ general_identification_answers = {}
+ # as we may have several questions populating the same field (e.g: the phone)
+ # we use this to hold the fields that have already been handled
+ # goal is to use the answer to the first question of every 'type' (aka name / phone / email / company name)
+ already_handled_fields_data = {}
for key, value in form_details.items():
- if 'question_answer' in key and value:
- dummy, registration_index, question_id = key.split('-')
- question_sudo = request.env['event.question'].browse(int(question_id))
- answer_values = None
- if question_sudo.question_type == 'simple_choice':
- answer_values = {
- 'question_id': int(question_id),
- 'value_answer_id': int(value)
- }
- elif question_sudo.question_type == 'text_box':
- answer_values = {
- 'question_id': int(question_id),
- 'value_text_box': value
- }
+ if not value:
+ continue
- if answer_values and not int(registration_index):
- general_answer_ids.append((0, 0, answer_values))
- elif answer_values:
- registrations.setdefault(registration_index, dict())\
- .setdefault('registration_answer_ids', list()).append((0, 0, answer_values))
- else:
- counter, attr_name = key.split('-', 1)
- field_name = attr_name.split('-')[0]
+ key_values = key.split('-')
+ # Special case for handling event_ticket_id data that holds only 2 values
+ if len(key_values) == 2:
+ registration_index, field_name = key_values
if field_name not in registration_fields:
continue
- elif isinstance(registration_fields[field_name], (fields.Many2one, fields.Integer)):
- value = int(value) or False # 0 is considered as a void many2one aka False
- else:
- value = value
+ registrations.setdefault(registration_index, dict())[field_name] = int(value)
+ continue
- if counter == '0':
- global_values[attr_name] = value
+ registration_index, question_type, question_id = key_values
+ answer_values = None
+ if question_type == 'simple_choice':
+ answer_values = {
+ 'question_id': int(question_id),
+ 'value_answer_id': int(value)
+ }
+ else:
+ answer_values = {
+ 'question_id': int(question_id),
+ 'value_text_box': value
+ }
+
+ if answer_values and not int(registration_index):
+ general_answer_ids.append((0, 0, answer_values))
+ elif answer_values:
+ registrations.setdefault(registration_index, dict())\
+ .setdefault('registration_answer_ids', list()).append((0, 0, answer_values))
+
+ if question_type in ('name', 'email', 'phone', 'company_name')\
+ and question_type not in already_handled_fields_data.get(registration_index, []):
+ if question_type not in registration_fields:
+ continue
+
+ field_name = question_type
+ already_handled_fields_data.setdefault(registration_index, list()).append(field_name)
+
+ if not int(registration_index):
+ general_identification_answers[field_name] = value
else:
- registrations.setdefault(counter, dict())[attr_name] = value
- for key, value in global_values.items():
- for registration in registrations.values():
- registration[key] = value
+ registrations.setdefault(registration_index, dict())[field_name] = value
if general_answer_ids:
for registration in registrations.values():
registration.setdefault('registration_answer_ids', list()).extend(general_answer_ids)
+ if general_identification_answers:
+ for registration in registrations.values():
+ registration.update(general_identification_answers)
+
return list(registrations.values())
def _create_attendees_from_registration_post(self, event, registration_data):
diff --git a/addons/website_event/data/event_demo.xml b/addons/website_event/data/event_demo.xml
index 5468167445b..0f12a338c79 100644
--- a/addons/website_event/data/event_demo.xml
+++ b/addons/website_event/data/event_demo.xml
@@ -1,5 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Get Inspired • Stay Connected • Have Fun
@@ -36,6 +60,10 @@