From 62c849521ef06aeff212cbdd7179a49155276233 Mon Sep 17 00:00:00 2001 From: "Djamel (otd)" Date: Fri, 26 Feb 2021 10:23:03 +0000 Subject: [PATCH] [FIX] survey: fix the function extract comment from the answers Steps to follow to reproduce the bug: -Go to survey -Choose any survey with at least one "single text box" question -In the survey form -Click on the button test -Complete the survey, but in a "single text box" question, write the word "comment" -Validate the survey -An error is triggered. Problem : In the function which extracts comments from answers, it doesn't check the type in which the answer is stored. When there is a comment, it is stored in a dict under the key: "comment". To find the comment, the function checks if "comment"(key) is in the answer. But in the case of "single text box" question, the answer is stored in a string. If the word "comment" is present in the answer, the function looking for the key "comment" will return True and try to extract the comment. Solution : Add a check to ensure that we are looking for the key "comment" in dict type. opw-2446194 closes odoo/odoo#67002 X-original-commit: 7064d46a804ab86d1bc50d003b8ae63490a1ef9c Signed-off-by: Anh Thao PHAM Signed-off-by: Djamel Touati --- addons/survey/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/survey/controllers/main.py b/addons/survey/controllers/main.py index 80b17617f47..300367cefcb 100644 --- a/addons/survey/controllers/main.py +++ b/addons/survey/controllers/main.py @@ -535,7 +535,7 @@ class Survey(http.Controller): if not isinstance(answers, list): answers = [answers] for answer in answers: - if 'comment' in answer: + if isinstance(answer, dict) and 'comment' in answer: comment = answer['comment'].strip() else: answers_no_comment.append(answer)