Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Events Organization
Entity: event.event
Compute Method: _compute_question_ids
| Inputs | Method | Outputs |
|---|---|---|
|
""" Update event questions from its event type. Depends are set only on
event_type_id itself to emulate an onchange. Changing event type content
itself should not trigger this method.
When synchronizing questions:
- * lines with no registered answers are removed;
+ * lines with no registered answers for the event are removed;
* type lines are added;
"""
- if self._origin.question_ids:
- # lines to keep: those with already given answers
- questions_tokeep_ids = self.env['event.registration.answer'].search(
- [('question_id', 'in', self._origin.question_ids.ids)]
- ).question_id.ids
- else:
- questions_tokeep_ids = []
for event in self:
- if not event.event_type_id and not event.question_ids:
+ questions_tokeep_ids = []
+ if self._origin.question_ids:
+ # Keep questions with attendee answers for the event.
+ questions_tokeep_ids.extend(
+ (event.registration_ids.registration_answer_ids.question_id & self._origin.question_ids).ids
+ )
+
+ if not event.event_type_id and not questions_tokeep_ids:
event.question_ids = self._default_question_ids()
continue
if questions_tokeep_ids:
questions_toremove = event._origin.question_ids.filtered(
lambda question: question.id not in questions_tokeep_ids)
command = [(3, question.id) for question in questions_toremove]
else:
command = [(5, 0)]
event.question_ids = command
-
- # copy questions so changes in the event don't affect the event type
- event.question_ids += event.event_type_id.question_ids.copy({
- 'event_type_id': False,
- })
+ event.question_ids = [Command.link(question_id.id) for question_id in event.event_type_id.question_ids]
|
|
