[FIX] survey_record_generation: unblock survey edition after a line without field #31
@@ -83,7 +83,7 @@ class SurveyRecordCreationFieldValues(models.Model):
|
||||
for record_creation_field_values in self:
|
||||
if not record_creation_field_values.survey_id or not record_creation_field_values.field_id:
|
||||
record_creation_field_values.allowed_question_ids = None
|
||||
return
|
||||
continue
|
||||
question_domain = [('survey_id','=',record_creation_field_values.survey_id.id)]
|
||||
|
||||
if record_creation_field_values.field_id.ttype in ['many2one','many2many']:
|
||||
|
||||
@@ -1096,3 +1096,31 @@ class TestSurveyRecordCreation(SurveyCase):
|
||||
self.assertEqual(self.answer.partner_id, jean)
|
||||
self.assertNotEqual(self.answer.partner_id, jeanne)
|
||||
self.assertEqual(self.answer.email, jean.email)
|
||||
|
||||
def test_allowed_questions_are_computed_after_a_line_without_field(self):
|
||||
# The administrator has added a line without choosing its field yet,
|
||||
# followed by a complete line
|
||||
FieldValues = self.env["survey.record.creation.field.values"]
|
||||
line_without_field = FieldValues.create(
|
||||
{
|
||||
"survey_record_creation_id": self.survey_record_creation.id,
|
||||
"value_origin": "fixed",
|
||||
}
|
||||
)
|
||||
line_with_field = FieldValues.create(
|
||||
{
|
||||
"survey_record_creation_id": self.survey_record_creation.id,
|
||||
"field_id": self.name_field.id,
|
||||
"value_origin": "question",
|
||||
"question_id": self.question_name.id,
|
||||
}
|
||||
)
|
||||
lines = line_without_field | line_with_field
|
||||
lines.invalidate_recordset(["allowed_question_ids"])
|
||||
|
||||
# Reading the lines together, as the survey form does, computes
|
||||
# the allowed questions of every line
|
||||
allowed = {line: line.allowed_question_ids for line in lines}
|
||||
|
||||
self.assertFalse(allowed[line_without_field])
|
||||
self.assertIn(self.question_name, allowed[line_with_field])
|
||||
|
||||
Reference in New Issue
Block a user