diff --git a/survey_user_input_domain/models/survey_user_input_line.py b/survey_user_input_domain/models/survey_user_input_line.py index c8fc66700e..7562a1cef4 100644 --- a/survey_user_input_domain/models/survey_user_input_line.py +++ b/survey_user_input_domain/models/survey_user_input_line.py @@ -6,15 +6,22 @@ class SurveyUserInputLine(models.Model): _inherit = "survey.user_input.line" - calculated_matrix_question_id = fields.Many2one( - comodel_name="survey.question", - string="Matrix Question ID", + calculated_matrix_question_ids = fields.Many2many( + comodel_name="survey.question.answer", + relation="survey_user_input_line_matrix_answer_rel", + column1="user_input_line_id", + column2="question_answer_id", + string="Matrix Question Answers", compute="_compute_matrix_question_id", store=True, ) - calculated_suggested_answer_question_id = fields.Many2one( - comodel_name="survey.question", - string="Suggested Answer ID", + + calculated_suggested_answer_question_ids = fields.Many2many( + comodel_name="survey.question.answer", + relation="survey_user_input_line_suggested_answer_rel", + column1="user_input_line_id", + column2="question_answer_id", + string="Suggested Answer Questions", compute="_compute_suggested_answer_id", store=True, ) @@ -22,15 +29,19 @@ class SurveyUserInputLine(models.Model): @api.depends("matrix_row_id", "matrix_row_id.matrix_question_id") def _compute_matrix_question_id(self): for line in self: - line.calculated_matrix_question_id = ( - line.matrix_row_id.matrix_question_id if line.matrix_row_id else False - ) + if line.matrix_row_id and line.matrix_row_id.matrix_question_id: + line.calculated_matrix_question_ids = ( + line.matrix_row_id.matrix_question_id.matrix_row_ids + ) + else: + line.calculated_matrix_question_ids = False @api.depends("suggested_answer_id", "suggested_answer_id.question_id") def _compute_suggested_answer_id(self): for line in self: - line.calculated_suggested_answer_question_id = ( - line.suggested_answer_id.question_id - if line.suggested_answer_id - else False - ) + if line.suggested_answer_id and line.suggested_answer_id.question_id: + line.calculated_suggested_answer_question_ids = ( + line.suggested_answer_id.question_id.suggested_answer_ids + ) + else: + line.calculated_suggested_answer_question_ids = False diff --git a/survey_user_input_domain/views/survey_user_input_form.xml b/survey_user_input_domain/views/survey_user_input_form.xml index 03879fb096..350e1351c5 100644 --- a/survey_user_input_domain/views/survey_user_input_form.xml +++ b/survey_user_input_domain/views/survey_user_input_form.xml @@ -1,20 +1,35 @@ - - survey.user_input.line - - - - "[('question_id', '=', record.suggested_answer_id.question_id)]" - + + + survey.user_input.line.view.form + survey.user_input.line + + + + + + + + - - "[('question_id', '=', record.matrix_row_id.question_id)]" + + [('id', '=', calculated_suggested_answer_question_ids)] + + + [('id', '=', calculated_matrix_question_ids)] + - - + +