Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Events

Entity: event.event

Compute Method: _compute_question_ids

View 17.0
Inputs Method Outputs
  • event_type_id
  • question_ids
- """ 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;
-           * 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:
-                 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
-             for question in event.event_type_id.question_ids:
-                 event.question_ids += question.copy({'event_type_id': False})
  • question_ids

Back to entity