[IMP] survey_event_registration_generation: add event_id to survey_user_input
This commit is contained in:
@@ -9,3 +9,5 @@ class SurveySurvey(models.Model):
|
|||||||
generate_registration = fields.Boolean(
|
generate_registration = fields.Boolean(
|
||||||
help="Generate registration for selected event",
|
help="Generate registration for selected event",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@@ -17,6 +17,16 @@ class SurveyUserInput(models.Model):
|
|||||||
|
|
||||||
registration_id = fields.Many2one('event.registration', 'Event registration')
|
registration_id = fields.Many2one('event.registration', 'Event registration')
|
||||||
|
|
||||||
|
event_id = fields.Many2one('event.event', 'Événement', compute='compute_event_id', store=True)
|
||||||
|
|
||||||
|
@api.depends('user_input_line_ids')
|
||||||
|
def compute_event_id(self):
|
||||||
|
for user_input in self:
|
||||||
|
for user_input_line in user_input.user_input_line_ids:
|
||||||
|
if user_input_line.answer_type == 'event':
|
||||||
|
user_input.event_id = user_input_line.value_event
|
||||||
|
break
|
||||||
|
|
||||||
def save_lines(self, question, answer, comment=None):
|
def save_lines(self, question, answer, comment=None):
|
||||||
"""
|
"""
|
||||||
Inherit save_lines method, called after each answer
|
Inherit save_lines method, called after each answer
|
||||||
@@ -68,6 +78,8 @@ class SurveyUserInput(models.Model):
|
|||||||
def _prepare_registration(self):
|
def _prepare_registration(self):
|
||||||
"""Extract registration values from the answers"""
|
"""Extract registration values from the answers"""
|
||||||
|
|
||||||
|
"""TODO: simplifier le code"""
|
||||||
|
|
||||||
elegible_inputs = self.user_input_line_ids.filtered(
|
elegible_inputs = self.user_input_line_ids.filtered(
|
||||||
lambda x: x.question_id.event_registration_field and not x.skipped
|
lambda x: x.question_id.event_registration_field and not x.skipped
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user