[IMP] survey_event_registration_generation: several dependant event questions in the same page (ajax)

This commit is contained in:
clementthomas
2023-09-27 18:49:32 +02:00
parent 6203bd95da
commit 96d2055903
4 changed files with 73 additions and 7 deletions

View File

@@ -3,8 +3,17 @@
from odoo.addons.survey.controllers import main
from odoo.http import request
from odoo import http
class Survey(main.Survey):
@http.route(['/survey_event/get_events_from_product'], type='json', auth="public", methods=['POST'])
def get_events_from_product(self, product_id, **kw):
tickets = request.env['event.event.ticket'].sudo().search([('product_id','=',product_id)])
events = set([ticket.event_id for ticket in tickets])
return [{'id':event.id,'name':event.name} for event in events]
def _prepare_survey_data(self, survey_sudo, answer_sudo, **post):
result = super(Survey, self)._prepare_survey_data(survey_sudo, answer_sudo, **post)
result['event_products'] = request.env['product.product'].sudo().search([('detailed_type','=','event')])