You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.3 KiB
58 lines
2.3 KiB
from collections import defaultdict
|
|
from odoo import _
|
|
from odoo.http import request, route
|
|
|
|
from odoo.addons.website_event_questions.controllers.main import WebsiteEventController
|
|
|
|
|
|
class WebsiteEventQep(WebsiteEventController):
|
|
# def _process_attendees_form(self, event, form_details):
|
|
# """Process data posted from the attendee details form.
|
|
# Extracts question answers:
|
|
# - For both questions asked 'once_per_order' and questions asked to every attendee
|
|
# - For questions of type 'simple_choice', extracting the suggested answer id
|
|
# - For questions of type 'text_box', extracting the text answer of the attendee.
|
|
# """
|
|
# registrations = super(WebsiteEvent, self)._process_attendees_form(
|
|
# event, form_details
|
|
# )
|
|
|
|
def _create_attendees_from_registration_post(self, event, registration_data):
|
|
if not any(info.get("event_ticket_id") for info in registration_data):
|
|
return super()._create_attendees_from_registration_post(
|
|
event, registration_data
|
|
)
|
|
|
|
res = super()._create_attendees_from_registration_post(event, registration_data)
|
|
|
|
order_sudo = request.website.sale_get_order(force_create=True)
|
|
|
|
reg_answers = {}
|
|
for data in registration_data:
|
|
answers = data.get("registration_answer_ids")
|
|
|
|
# tickets_data = defaultdict(int)
|
|
# for data in registration_data:
|
|
# event_ticket_id = data.get("event_ticket_id")
|
|
# if event_ticket_id:
|
|
# tickets_data[event_ticket_id] += 1
|
|
|
|
# cart_data = {}
|
|
# for ticket_id, count in tickets_data.items():
|
|
# ticket_sudo = request.env["event.event.ticket"].sudo().browse(ticket_id)
|
|
# cart_values = order_sudo._cart_update(
|
|
# product_id=ticket_sudo.product_id.id,
|
|
# add_qty=count,
|
|
# event_ticket_id=ticket_id,
|
|
# )
|
|
# cart_data[ticket_id] = cart_values["line_id"]
|
|
|
|
# for data in registration_data:
|
|
# event_ticket_id = data.get("event_ticket_id")
|
|
# if event_ticket_id:
|
|
# data["sale_order_id"] = order_sudo.id
|
|
# data["sale_order_line_id"] = cart_data[event_ticket_id]
|
|
|
|
request.session["website_sale_cart_quantity"] = order_sudo.cart_quantity
|
|
|
|
return res
|