This commit is contained in:
2025-08-21 12:31:41 +02:00
parent 963fc5b9c0
commit 853ed418bb
3 changed files with 19 additions and 10 deletions

View File

@@ -33,7 +33,7 @@ class SurveyRecordCreationFieldValues(models.Model):
field_id = fields.Many2one(
'ir.model.fields',
domain="[('model_id','=',model_id),('readonly','=',False),('ttype','in',['char','selection','text','html','integer','float','date','datetime','many2one','many2many'])]",
domain="[('model_id','=',model_id),('readonly','=',False),('ttype','in',['char','selection','text','html','integer','float','date','datetime','many2one','many2many', 'boolean'])]",
ondelete="cascade")
field_relation = fields.Char(related='field_id.relation')
field_type = fields.Selection(related="field_id.ttype")
@@ -58,6 +58,7 @@ class SurveyRecordCreationFieldValues(models.Model):
fixed_value_float = fields.Float("Value")
fixed_value_date = fields.Date("Value")
fixed_value_datetime = fields.Datetime("Value")
fixed_value_boolean = fields.Boolean("Value")
displayed_value = fields.Char("Value", compute="_compute_displayed_value")
other_created_record_id = fields.Many2one("survey.record.creation", string="Other record", domain="[('survey_id','=',survey_id),('model_id.model','=',field_relation)]")

View File

@@ -63,7 +63,11 @@ class SurveyUserInput(models.Model):
else:
vals[field_value.field_id.name] = record_ids
if field_value.question_id.answer_values_type == 'value':
vals[field_value.field_id.name] = user_input_lines[0].suggested_answer_id.value_char
if field_value.field_id.ttype == "boolean":
boolean_value = user_input_lines[0].suggested_answer_id.value_char in [True, 1, "1", "True", "true", "Oui", "oui"]
vals[field_value.field_id.name] = boolean_value
else:
vals[field_value.field_id.name] = user_input_lines[0].suggested_answer_id.value_char
elif user_input_lines[0].answer_type: # if value not filled by user, answer_type not set
vals[field_value.field_id.name] = user_input_lines[0][f"value_{user_input_lines[0].answer_type}"]
else: