summaryrefslogtreecommitdiff
path: root/addons/website_event
diff options
context:
space:
mode:
authorJérémy Hennecart <jeh@odoo.com>2020-05-15 12:52:25 +0000
committerThibault Delavallée <tde@odoo.com>2020-05-18 11:58:56 +0000
commitd01144e17d8cf0d8fdf106e307f36d871d0d8737 (patch)
treebae631c8b8231f2fb09ffeaa321d22c1e7bdab55 /addons/website_event
parent83a7fb5f9215c5cebcca547e62bb06fde716b05f (diff)
[REF] website_event(_sale): create registrations in batch when buying tickets
PURPOSE Create event registrations in batch. It will allow to customize group-creation of registrations, notably with automated rules for crm / event synchronization. SPECIFICATIONS Instead of creating registrations one by one when processing registration form details, simply batch-ize their creation. Instead of creating registrations one by one when adding a new line in cart simply let website_event handle its job, or the confirmation action of a sale order that already populates registrations. Creating registrations when adding a cart line has no real use as we have no specific information to create that registration. It is better to let the flow finish and create additional registrations in batch once SO is confirmed. LINKS Task ID 2258685 Prepare Task ID 2166679 (create leads from registrations) PR odoo/odoo#51341 Co-Authored-By: Jeremy Hennecart <jeh@odoo.com> Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Diffstat (limited to 'addons/website_event')
-rw-r--r--addons/website_event/controllers/main.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py
index 48b6b19936c..f0c5351801f 100644
--- a/addons/website_event/controllers/main.py
+++ b/addons/website_event/controllers/main.py
@@ -332,15 +332,14 @@ class WebsiteEventController(http.Controller):
return list(registrations.values())
def _create_attendees_from_registration_post(self, event, registration_data):
- attendees_sudo = request.env['event.registration'].sudo()
-
+ registrations_to_create = []
for registration_values in registration_data:
registration_values['event_id'] = event.id
if not registration_values.get('partner_id'):
registration_values['partner_id'] = request.env.user.partner_id.id
- attendees_sudo += request.env['event.registration'].sudo().create(registration_values)
+ registrations_to_create.append(registration_values)
- return attendees_sudo
+ return request.env['event.registration'].sudo().create(registrations_to_create)
@http.route(['''/event/<model("event.event"):event>/registration/confirm'''], type='http', auth="public", methods=['POST'], website=True)
def registration_confirm(self, event, **post):