[FIX]survey_record_generation:fix IndexError when record value is empty

This commit is contained in:
2025-09-22 14:26:56 +02:00
committed by elabore_bot
parent a1a3a77ee0
commit 4919564228
2 changed files with 5 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ Allow to create record of any model when sending the form :
* Associate question with fields * Associate question with fields
* For x2m fields : Associate values to questions * For x2m fields : Associate values to questions
""", """,
"version": "16.0.1.0.1", "version": "16.0.1.0.2",
"license": "AGPL-3", "license": "AGPL-3",
"author": "Elabore", "author": "Elabore",
"website": "https://www.elabore.coop", "website": "https://www.elabore.coop",

View File

@@ -59,7 +59,10 @@ class SurveyUserInput(models.Model):
if user_input_line.suggested_answer_id and user_input_line.suggested_answer_id.record_id: if user_input_line.suggested_answer_id and user_input_line.suggested_answer_id.record_id:
record_ids.append(user_input_line.suggested_answer_id.record_id.id) record_ids.append(user_input_line.suggested_answer_id.record_id.id)
if field_value.question_id.question_type == 'simple_choice': if field_value.question_id.question_type == 'simple_choice':
vals[field_value.field_id.name] = record_ids[0] if record_ids:
vals[field_value.field_id.name] = record_ids[0]
else:
vals[field_value.field_id.name] = None
else: else:
vals[field_value.field_id.name] = record_ids vals[field_value.field_id.name] = record_ids
if field_value.question_id.answer_values_type == 'value': if field_value.question_id.answer_values_type == 'value':