From efd748c4cae8a02bd3bce15317d778b64eed29a8 Mon Sep 17 00:00:00 2001 From: "Richard Mathot (OpenERP)" Date: Mon, 16 Dec 2013 08:37:43 +0100 Subject: [PATCH] [IMP] Saving survey data bzr revid: rim@openerp.com-20131216073743-j0sdavdqprp2xawl --- addons/survey/survey.py | 42 ++++++++++++------------ addons/survey/views/survey_templates.xml | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index bcdfb136052..b7a6d3d9522 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -1025,7 +1025,7 @@ class survey_user_input_line(osv.osv): 'page_id': question.page_id.id, 'survey_id': question.survey_id.id, } - if answer_tag in post: + if answer_tag in post and post[answer_tag].strip() != '': vals.update({'answer_type': 'date', 'value_date': post[answer_tag]}) else: vals.update({'skipped': True}) @@ -1039,26 +1039,26 @@ class survey_user_input_line(osv.osv): self.create(cr, uid, vals, context=context) return True - # def save_line_simple_choice(self, cr, uid, user_input_id, question, post, answer_tag, context=None): - # vals = { - # 'user_input_id': user_input_id, - # 'question_id': question.id, - # 'page_id': question.page_id.id, - # 'survey_id': question.survey_id.id, - # } - # if answer_tag in post: - # vals.update({'answer_type': 'date', 'value_date': post[answer_tag]}) - # else: - # vals.update({'skipped': True}) - # old_uil = self.search(cr, uid, [('user_input_id', '=', user_input_id), - # ('survey_id', '=', question.survey_id.id), - # ('question_id', '=', question.id)], - # context=context) - # if old_uil: - # self.write(cr, uid, old_uil[0], vals, context=context) - # else: - # self.create(cr, uid, vals, context=context) - # return True + def save_line_simple_choice(self, cr, uid, user_input_id, question, post, answer_tag, context=None): + vals = { + 'user_input_id': user_input_id, + 'question_id': question.id, + 'page_id': question.page_id.id, + 'survey_id': question.survey_id.id, + } + if answer_tag in post and post[answer_tag].strip() != '': + vals.update({'answer_type': 'date', 'value_date': post[answer_tag]}) + else: + vals.update({'skipped': True}) + old_uil = self.search(cr, uid, [('user_input_id', '=', user_input_id), + ('survey_id', '=', question.survey_id.id), + ('question_id', '=', question.id)], + context=context) + if old_uil: + self.write(cr, uid, old_uil[0], vals, context=context) + else: + self.create(cr, uid, vals, context=context) + return True def dict_keys_startswith(dictionary, string): diff --git a/addons/survey/views/survey_templates.xml b/addons/survey/views/survey_templates.xml index d59f49d81fd..b2798c0370f 100644 --- a/addons/survey/views/survey_templates.xml +++ b/addons/survey/views/survey_templates.xml @@ -147,7 +147,7 @@