diff options
| author | Debauche Stéphane <std@odoo.com> | 2020-02-04 08:06:28 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-02-18 15:59:12 +0000 |
| commit | 3721f49d4e64f29eb07686787bef77797fc69bc8 (patch) | |
| tree | e71a471e49b9a8f7fb62006a84a133cf697e9754 /addons/website_event_questions/controllers | |
| parent | 9b55dfcc35f660fe94e376d14e63d30c33c068b1 (diff) | |
[FIX] website_event(_questions): correctly parse frontend question answers
When user register to an event from website, they can answer questions
specific to a given registration or to all registrations. However they
are not correctly parsed and not saved.
Task 2188857
PR #44545
X-original-commit: e27d9b5c4f234f6ce64456c2f52e7cfb0331332f
Diffstat (limited to 'addons/website_event_questions/controllers')
| -rw-r--r-- | addons/website_event_questions/controllers/main.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/addons/website_event_questions/controllers/main.py b/addons/website_event_questions/controllers/main.py index bc8f98f1678..a24ccc941f9 100644 --- a/addons/website_event_questions/controllers/main.py +++ b/addons/website_event_questions/controllers/main.py @@ -9,10 +9,20 @@ class WebsiteEvent(WebsiteEventController): def _process_attendees_form(self, event, form_details): ''' Process data posted from the attendee details form. ''' registrations = super(WebsiteEvent, self)._process_attendees_form(event, form_details) + for registration in registrations: - answer_ids = [] - for key, value in registration.items(): - if key.startswith('answer_ids-'): - answer_ids.append([4, int(value)]) - registration['answer_ids'] = answer_ids + registration['answer_ids'] = [] + + general_answer_ids = [] + for key, value in form_details.items(): + if 'answer_ids' in key: + index = int(key.split('-')[0]) + if not index: + general_answer_ids.append([4, int(value)]) + else: + registrations[index-1]['answer_ids'].append([4, int(value)]) + + for registration in registrations: + registration['answer_ids'].extend(general_answer_ids) + return registrations |
