From 489aea8520945e1b2925b6b1eb172a664f46a05f Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Mon, 1 Feb 2010 19:01:10 +0530 Subject: [PATCH] [IMP]:Survey:Ref.YSA * Improved the code and changes in view,fix bug in report and response wizard. bzr revid: apa@tinyerp.com-20100201133110-de1jvtbom7t06iks --- .../survey/report/survey_analysis_report.py | 2 + .../survey/report/survey_browse_response.py | 12 +++--- addons/survey/survey.py | 22 ++++++---- addons/survey/survey_view.xml | 41 ++++++++++--------- 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/addons/survey/report/survey_analysis_report.py b/addons/survey/report/survey_analysis_report.py index 79871a63084..069488034d8 100755 --- a/addons/survey/report/survey_analysis_report.py +++ b/addons/survey/report/survey_analysis_report.py @@ -257,6 +257,8 @@ class survey_analysis(report_rml): sqc.question_id = sr.question_id and sra.answer_id = %d and sqc.title ='%s'\ group by sra.answer_id,sqc.rating_weight" % (ans.id,matrix_ans[mat_col])) col_weight = cr.fetchone() + if not col_weight : + col_weight= (0,0) res_count = col_weight[0] if tot_res: rating_weight_sum += col_weight[1] * tot_res diff --git a/addons/survey/report/survey_browse_response.py b/addons/survey/report/survey_browse_response.py index 26ac0e54103..6e26f21e5b3 100644 --- a/addons/survey/report/survey_browse_response.py +++ b/addons/survey/report/survey_browse_response.py @@ -268,7 +268,7 @@ class survey_browse_response(report_rml): """ elif que.type in ['matrix_of_choices_only_one_ans','matrix_of_choices_only_multi_ans','rating_scale','matrix_of_drop_down_menus']: if len(answer) and answer[0].state == "done": - if que.comment_column: + if que.type in ['matrix_of_choices_only_one_ans','rating_scale'] and que.comment_column: pass cols_widhts = [] cols_widhts.append(200) @@ -278,7 +278,7 @@ class survey_browse_response(report_rml): tmp=0.0 sum = 0.0 i = 0 - if que.comment_column: + if que.type in ['matrix_of_choices_only_one_ans','rating_scale'] and que.comment_column: for col in cols_widhts: if i==0: cols_widhts[i] = cols_widhts[i]/2.0 @@ -292,7 +292,7 @@ class survey_browse_response(report_rml): if col.title not in matrix_ans: matrix_ans.append(col.title) len_matrix = len(matrix_ans) - if que.comment_column: + if que.type in ['matrix_of_choices_only_one_ans','rating_scale'] and que.comment_column: matrix_ans.append(que.column_name) rml+="""""" for mat_col in matrix_ans: @@ -342,14 +342,14 @@ class survey_browse_response(report_rml): """ rml+= """""" + value + """""" - if que.comment_column: + if que.type in ['matrix_of_choices_only_one_ans','rating_scale'] and que.comment_column: if comment_value=='False': comment_value = '' rml+= """"""+ to_xml(tools.ustr(comment_value)) + """""" rml+=""" """ - if que.comment_field_type: + if que.is_comment_require: rml+=""" - """ + to_xml(tools.ustr(answer[0].comment)) + """""" + """ + to_xml(tools.ustr(answer[0].comment or '')) + """""" else: rml +=""" No Response diff --git a/addons/survey/survey.py b/addons/survey/survey.py index c6a4a1daf2b..632f4c768ef 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -331,9 +331,9 @@ class survey_question(osv.osv): raise osv.except_osv(_('Error !'),_("Maximum Required Answer is greater than Minimum Required Answer")) if question['type'] == 'matrix_of_drop_down_menus' and vals.has_key('column_heading_ids'): for col in vals['column_heading_ids']: - if col[2].has_key('menu_choice') and not col[2]['menu_choice']: + if col[2] and col[2].has_key('menu_choice') and not col[2]['menu_choice']: raise osv.except_osv(_('Error !'),_("You must enter one or more menu choices in column heading")) - elif col[2].has_key('menu_choice') and col[2]['menu_choice'].strip() == '': + elif col[2] and col[2].has_key('menu_choice') and col[2]['menu_choice'].strip() == '': raise osv.except_osv(_('Error !'),_("You must enter one or more menu choices in column heading (white spaces not allowed)")) return super(survey_question, self).write(cr, uid, ids, vals, context=context) @@ -740,24 +740,28 @@ class survey_question_wiz(osv.osv_memory): fields[tools.ustr(que) + "_commentcolumn_"+tools.ustr(row['id']) + "_field"] = {'type':'char', 'size' : 255, 'string':tools.ustr(que_rec['column_name']), 'views':{}} etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_commentcolumn_"+tools.ustr(row['id'])+ "_field"}) elif que_rec['type'] == 'matrix_of_choices_only_multi_ans': - xml_group = etree.SubElement(xml_group, 'group', {'col': '2', 'colspan': '2'}) + xml_group = etree.SubElement(xml_group, 'group', {'col': str(len(que_rec['column_heading_ids']) + 1), 'colspan': '4'}) + etree.SubElement(xml_group, 'separator', {'string': '.','colspan': '1'}) + for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']): + etree.SubElement(xml_group, 'separator', {'string': tools.ustr(col['title']),'colspan': '1'}) for row in ans_ids: etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(row['answer'])) +' :-', 'align': '0.0'}) - etree.SubElement(xml_group, 'newline') for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']): - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title'])}) + etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title']), 'nolabel':"1"}) fields[tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title'])] = {'type':'boolean', 'string': col['title']} elif que_rec['type'] == 'matrix_of_drop_down_menus': - xml_group = etree.SubElement(xml_group, 'group', {'col': '2', 'colspan': '2'}) + xml_group = etree.SubElement(xml_group, 'group', {'col': str(len(que_rec['column_heading_ids']) + 1), 'colspan': '4'}) + etree.SubElement(xml_group, 'separator', {'string': '.','colspan': '1'}) + for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']): + etree.SubElement(xml_group, 'separator', {'string': tools.ustr(col['title']),'colspan': '1'}) for row in ans_ids: etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(row['answer']))+' :-', 'align': '0.0'}) - etree.SubElement(xml_group, 'newline') for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']): selection = [] if col['menu_choice']: for item in col['menu_choice'].split('\n'): if item and not item.strip() == '': selection.append((item ,item)) - etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title'])}) + etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title']),'nolabel':'1'}) fields[tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['title'])] = {'type':'selection', 'string': col['title'], 'selection':selection} elif que_rec['type'] == 'multiple_textboxes': xml_group = etree.SubElement(xml_group, 'group', {'col': '1', 'colspan': '4'}) @@ -1238,7 +1242,7 @@ class survey_question_wiz(osv.osv_memory): numeric_sum += int(val) elif val and len(key.split('_')) == 3: resp_obj.write(cr, uid, update, {'state': 'done'}) - if type(val) == type(''): + if type(val) == type('') or type(val) == type(u''): ans_create_id = res_ans_obj.create(cr, uid, {'response_id':update, 'answer_id':ans_id_len[1], 'answer' : ans_id_len[2], 'value_choice' : val}) sur_name_read['store_ans'][update].update({key:val}) else: diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml index 70b41b589fe..5085ed4986d 100644 --- a/addons/survey/survey_view.xml +++ b/addons/survey/survey_view.xml @@ -30,7 +30,7 @@