From b7989fbeecba1f59de074b51e4e52bbabb87b714 Mon Sep 17 00:00:00 2001 From: "Richard Mathot (OpenERP)" Date: Thu, 10 Apr 2014 16:52:47 +0200 Subject: [PATCH] [FIX] Correct saving of comments bzr revid: rim@openerp.com-20140410145247-o2759q0r022ybp4q --- addons/survey/survey.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index e2006cfbf3c..35b00a6ef07 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -1148,11 +1148,15 @@ class survey_user_input_line(osv.Model): self.unlink(cr, uid, old_uil, context=context) ca = dict_keys_startswith(post, answer_tag) + comment_answer = ca.pop(("%s_%s" % (answer_tag, 'comment')), '').strip() if len(ca) > 0: for a in ca: vals.update({'answer_type': 'suggestion', 'value_suggested': ca[a]}) self.create(cr, uid, vals, context=context) - else: + if comment_answer: + vals.update({'answer_type': 'text', 'value_text': comment_answer}) + self.create(cr, uid, vals, context=context) + if not ca and not comment_answer: vals.update({'answer_type': None, 'skipped': True}) self.create(cr, uid, vals, context=context) return True @@ -1172,8 +1176,14 @@ class survey_user_input_line(osv.Model): if old_uil: self.unlink(cr, uid, old_uil, context=context) - ca = dict_keys_startswith(post, answer_tag) no_answers = True + ca = dict_keys_startswith(post, answer_tag) + + comment_answer = ca.pop(("%s_%s" % (answer_tag, 'comment')), '').strip() + if comment_answer: + vals.update({'answer_type': 'text', 'value_text': comment_answer}) + self.create(cr, uid, vals, context=context) + no_answers = False if question.matrix_subtype == 'simple': for row in question.labels_ids_2: