33from odoo import api , fields , models
44
55
6+ # This class is to format questions of type (yes, no)
7+ # in case we need the answer as (True, False) in case of filling checkboxes
68class SurveyUtils :
79 @staticmethod
810 def is_yes_no_answer (value ):
@@ -22,7 +24,7 @@ def format_answer(answer):
2224class SignOcaRequest (models .Model ):
2325 _inherit = "sign.oca.request"
2426
25- # This field is required for the inverse of maintenance.equipment .
27+ # This field is required for the inverse of survey.user.input .
2628 survey_user_input_id = fields .Many2one (
2729 comodel_name = "survey.user_input" ,
2830 compute = "_compute_survey_user_input_id" ,
@@ -51,6 +53,8 @@ def get_related_survey_answers(self):
5153 survey = {}
5254 if survey_participation and model_id and model_id .model == "survey.user_input" :
5355 for line in survey_participation .user_input_line_ids :
56+ # Questions of type matrix have questions and suggested answers like a matrix
57+ # We map the answeres to the questions for each matrix type
5458 if line .question_id .question_type == "matrix" :
5559 answer = line .suggested_answer_id .value
5660 survey .update ({line .matrix_row_id .value : answer })
@@ -68,6 +72,9 @@ def fill_survey_related_items(self, vals):
6872 for key in items :
6973 item = items [key ]
7074 placeholder = item .get ("placeholder" )
75+ # According to placeholder we target the answer of a question
76+ # having same text as the placeholder
77+ # and we choose the answer format based on the item field_typ
7178 if survey .get (placeholder ) and item ["role_id" ] == self .role_id .id :
7279 if survey .get (placeholder ) and item ["field_type" ] == "text" :
7380 item ["value" ] = survey .get (placeholder )
0 commit comments