From ec804d42f5004368fa1c443660896079a1669834 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 22 Feb 2013 11:09:50 +0100 Subject: [PATCH] [IMP] survey: statistics bzr revid: chm@openerp.com-20130222100950-8ica4v4bpx4nbdvu --- addons/survey/__openerp__.py | 2 +- .../survey/report/survey_analysis_report.py | 22 ++++---- addons/survey/survey.py | 37 +++++++++---- addons/survey/survey_view.xml | 14 ++--- addons/survey/wizard/survey_answer.py | 52 +++++++++++-------- addons/survey/wizard/survey_browse_answer.xml | 4 ++ .../wizard/survey_email_compose_message.xml | 2 +- addons/survey/wizard/survey_print_answer.xml | 3 ++ .../survey/wizard/survey_print_statistics.py | 1 + .../survey/wizard/survey_print_statistics.xml | 3 ++ addons/survey/wizard/survey_selection.xml | 11 ++-- 11 files changed, 98 insertions(+), 53 deletions(-) diff --git a/addons/survey/__openerp__.py b/addons/survey/__openerp__.py index 6882690782a..0504cfe35d7 100644 --- a/addons/survey/__openerp__.py +++ b/addons/survey/__openerp__.py @@ -38,7 +38,6 @@ user name and password for the invitation of the survey. 'data': [ 'survey_report.xml', 'survey_data.xml', - 'wizard/survey_selection.xml', 'wizard/survey_answer.xml', 'security/survey_security.xml', 'security/ir.model.access.csv', @@ -48,6 +47,7 @@ user name and password for the invitation of the survey. 'wizard/survey_browse_answer.xml', 'wizard/survey_print.xml', 'wizard/survey_email_compose_message.xml', + #'wizard/survey_selection.xml', ], 'demo': ['survey_demo.xml'], 'test': [ diff --git a/addons/survey/report/survey_analysis_report.py b/addons/survey/report/survey_analysis_report.py index f7f08df3d65..03e03478f00 100644 --- a/addons/survey/report/survey_analysis_report.py +++ b/addons/survey/report/survey_analysis_report.py @@ -239,16 +239,16 @@ class survey_analysis(report_rml): rml += """""" if que.is_comment_require: -# if que.make_comment_field: -# cr.execute("select count(id) from survey_response_line where question_id = %s and comment != ''", (que.id,)) -# tot_res = cr.fetchone()[0] -# tot_avg = 0.00 -# if que.tot_resp: -# tot_avg = round(float(tot_res * 100)/ que.tot_resp,2) -# rml+="""""" +to_xml(tools.ustr(que.comment_label)) + """ -# """ + str(tot_avg) + """% -# """ + tools.ustr(tot_res) + """""" -# else: + # if que.make_comment_field: + # cr.execute("select count(id) from survey_response_line where question_id = %s and comment != ''", (que.id,)) + # tot_res = cr.fetchone()[0] + # tot_avg = 0.00 + # if que.tot_resp: + # tot_avg = round(float(tot_res * 100)/ que.tot_resp,2) + # rml+="""""" +to_xml(tools.ustr(que.comment_label)) + """ + # """ + str(tot_avg) + """% + # """ + tools.ustr(tot_res) + """""" + # else: cr.execute("select count(id) from survey_response_line where question_id = %s and comment != ''", (que.id,)) tot_res = cr.fetchone()[0] rml += """""" + to_xml(tools.ustr(que.comment_label)) + """ @@ -304,7 +304,7 @@ class survey_analysis(report_rml): cr.execute("select count(sra.answer_id),sqc.rating_weight from survey_response_line sr, survey_response_answer sra ,\ survey_question_column_heading sqc where sr.id = sra.response_id and \ sqc.question_id = sr.question_id and sra.answer_id = %s and sqc.title ='%s'\ -+ group by sra.answer_id,sqc.rating_weight", (ans.id,matrix_ans[mat_col][1])) + group by sra.answer_id,sqc.rating_weight", (ans.id,matrix_ans[mat_col][1])) col_weight = cr.fetchone() if not col_weight: diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 2a065e146d2..8f429deeed3 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -173,6 +173,23 @@ class survey(osv.osv): } return report + def print_statistics(self, cr, uid, ids, context=None): + """ + Print Survey Statistics in pdf format. + """ + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'survey.analysis', + 'datas': { + 'model': 'survey.print.statistics', + 'ids': [], + 'form': { + 'id': None, + 'survey_ids': ids + }, + }, + } + def _check_valid(self, cr, uid, ids, context=None): sur_browse = self.browse(cr, uid, ids[0], context=context) if not sur_browse.page_ids: @@ -182,14 +199,15 @@ class survey(osv.osv): self._check_valid(cr, uid, ids, context=context) id = ids[0] - context.update({'active': False, 'survey_id': id}) + survey = self.browse(cr, uid, id, context=context) + context.update({'edit': False, 'survey_id': id, 'survey_token': survey.token}) return { 'view_type': 'form', 'view_mode': 'form', 'res_model': 'survey.question.wiz', 'type': 'ir.actions.act_window', 'target': 'inline', - 'name': self.browse(cr, uid, id, context=context).title, + 'name': survey.title, 'context': context } @@ -197,7 +215,6 @@ class survey(osv.osv): id = ids[0] context.update({ 'survey_id': id, - 'active': True, 'edit': True, 'ir_actions_act_window_target': 'new', }) @@ -392,18 +409,18 @@ class survey_question(osv.osv): } _defaults = { 'sequence': 1, - 'type': 'multiple_choice_multiple_ans', - 'req_error_msg': 'This question requires an answer.', + 'type': lambda s, cr, uid, c: _('multiple_choice_multiple_ans'), + 'req_error_msg': lambda s, cr, uid, c: _('This question requires an answer.'), 'required_type': 'at least', 'req_ans': 1, 'comment_field_type': 'char', - 'comment_label': 'Other (please specify)', + 'comment_label': lambda s, cr, uid, c: _('Other (please specify)'), 'comment_valid_type': 'do_not_validate', - 'comment_valid_err_msg': 'The comment you entered is in an invalid format.', + 'comment_valid_err_msg': lambda s, cr, uid, c: _('The comment you entered is in an invalid format.'), 'validation_type': 'do_not_validate', - 'validation_valid_err_msg': 'The comment you entered is in an invalid format.', - 'numeric_required_sum_err_msg': 'The choices need to add up to [enter sum here].', - 'make_comment_field_err_msg': 'Please enter a comment.', + 'validation_valid_err_msg': lambda s, cr, uid, c: _('The comment you entered is in an invalid format.'), + 'numeric_required_sum_err_msg': lambda s, cr, uid, c: _('The choices need to add up to [enter sum here].'), + 'make_comment_field_err_msg': lambda s, cr, uid, c: _('Please enter a comment.'), 'in_visible_answer_type': 1 } diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml index 91de8466317..ccd7257efff 100644 --- a/addons/survey/survey_view.xml +++ b/addons/survey/survey_view.xml @@ -6,7 +6,9 @@ - + + + @@ -227,9 +229,9 @@