diff --git a/addons/survey/report/__init__.py b/addons/survey/report/__init__.py index 26fc1d46d63..a186b3da4c9 100644 --- a/addons/survey/report/__init__.py +++ b/addons/survey/report/__init__.py @@ -1,27 +1,27 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved -# $Id$ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# # -*- encoding: utf-8 -*- +# ############################################################################## +# # +# # OpenERP, Open Source Management Solution +# # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# # $Id$ +# # +# # This program is free software: you can redistribute it and/or modify +# # it under the terms of the GNU Affero General Public License as published by +# # the Free Software Foundation, either version 3 of the License, or +# # (at your option) any later version. +# # +# # This program is distributed in the hope that it will be useful, +# # but WITHOUT ANY WARRANTY; without even the implied warranty of +# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# # GNU Affero General Public License for more details. +# # +# # You should have received a copy of the GNU Affero General Public License +# # along with this program. If not, see . +# # +# ############################################################################## -import survey_analysis_report -import survey_form -import survey_browse_response +# import survey_analysis_report +# import survey_form +# import survey_browse_response -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/survey/report/survey_analysis_report.py b/addons/survey/report/survey_analysis_report.py index c06f4133890..94dffac25d3 100644 --- a/addons/survey/report/survey_analysis_report.py +++ b/addons/survey/report/survey_analysis_report.py @@ -1,385 +1,385 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved -# $Id$ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# # -*- encoding: utf-8 -*- +# ############################################################################## +# # +# # OpenERP, Open Source Management Solution +# # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# # $Id$ +# # +# # This program is free software: you can redistribute it and/or modify +# # it under the terms of the GNU Affero General Public License as published by +# # the Free Software Foundation, either version 3 of the License, or +# # (at your option) any later version. +# # +# # This program is distributed in the hope that it will be useful, +# # but WITHOUT ANY WARRANTY; without even the implied warranty of +# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# # GNU Affero General Public License for more details. +# # +# # You should have received a copy of the GNU Affero General Public License +# # along with this program. If not, see . +# # +# ############################################################################## -import time +# import time -import openerp -from openerp import tools -from openerp.report import report_sxw -from openerp.report.interface import report_rml -from openerp.tools import to_xml +# import openerp +# from openerp import tools +# from openerp.report import report_sxw +# from openerp.report.interface import report_rml +# from openerp.tools import to_xml -class survey_analysis(report_rml): - def create(self, cr, uid, ids, datas, context): - registry = openerp.registry(cr.dbname) - surv_obj = registry['survey'] - user_obj = registry['res.users'] - rml_obj=report_sxw.rml_parse(cr, uid, surv_obj._name,context) - company=user_obj.browse(cr,uid,[uid],context)[0].company_id +# class survey_analysis(report_rml): +# def create(self, cr, uid, ids, datas, context): +# registry = openerp.registry(cr.dbname) +# surv_obj = registry['survey'] +# user_obj = registry['res.users'] +# rml_obj=report_sxw.rml_parse(cr, uid, surv_obj._name,context) +# company=user_obj.browse(cr,uid,[uid],context)[0].company_id - rml =""" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """ +# rml =""" +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# """ - if datas.has_key('form') and datas['form']['survey_ids']: - ids = datas['form']['survey_ids'] +# if datas.has_key('form') and datas['form']['survey_ids']: +# ids = datas['form']['survey_ids'] - for survey in surv_obj.browse(cr, uid, ids): - rml += """ - Answers Summary - - - - - - - - Survey Title - - - Total Started Survey - - - Total Completed Survey - - - - - - - """ + to_xml(tools.ustr(survey.title)) + """ - - - """ + str(survey.tot_start_survey) + """ - - - """ + str(survey.tot_comp_survey) + """ - - - - - - """ - for page in survey.page_ids: - rml += """ - - Page :- """ + to_xml(tools.ustr(page.title)) + """ - - """ - for que in page.question_ids: - rml +=""" - - """ + to_xml(tools.ustr(que.question)) + """ - - """ - cols_widhts = [] +# for survey in surv_obj.browse(cr, uid, ids): +# rml += """ +# Answers Summary +# +# +# +# +# +# +# +# Survey Title +# +# +# Total Started Survey +# +# +# Total Completed Survey +# +# +# +# +# +# +# """ + to_xml(tools.ustr(survey.title)) + """ +# +# +# """ + str(survey.tot_start_survey) + """ +# +# +# """ + str(survey.tot_comp_survey) + """ +# +# +# +# +# +# """ +# for page in survey.page_ids: +# rml += """ +# +# Page :- """ + to_xml(tools.ustr(page.title)) + """ +# +# """ +# for que in page.question_ids: +# rml +=""" +# +# """ + to_xml(tools.ustr(que.question)) + """ +# +# """ +# cols_widhts = [] - if que.type in ['matrix_of_choices_only_one_ans','matrix_of_choices_only_multi_ans']: - cols_widhts.append(200) - for col in range(0, len(que.column_heading_ids) + 1): - cols_widhts.append(float(300 / (len(que.column_heading_ids) + 1))) - colWidths = ",".join(map(tools.ustr, cols_widhts)) - matrix_ans = [(0,'')] +# if que.type in ['matrix_of_choices_only_one_ans','matrix_of_choices_only_multi_ans']: +# cols_widhts.append(200) +# for col in range(0, len(que.column_heading_ids) + 1): +# cols_widhts.append(float(300 / (len(que.column_heading_ids) + 1))) +# colWidths = ",".join(map(tools.ustr, cols_widhts)) +# matrix_ans = [(0,'')] - for col in que.column_heading_ids: - if col.title not in matrix_ans: - matrix_ans.append((col.id,col.title)) - rml += """""" - for mat_col in range(0, len(matrix_ans)): - rml+="""""" + to_xml(tools.ustr(matrix_ans[mat_col][1])) + """""" - rml += """Answer Count - """ - last_col = cols_widhts[-1] +# for col in que.column_heading_ids: +# if col.title not in matrix_ans: +# matrix_ans.append((col.id,col.title)) +# rml += """""" +# for mat_col in range(0, len(matrix_ans)): +# rml+="""""" + to_xml(tools.ustr(matrix_ans[mat_col][1])) + """""" +# rml += """Answer Count +# """ +# last_col = cols_widhts[-1] - for ans in que.answer_choice_ids: - rml += """""" + to_xml(tools.ustr(ans.answer)) + """""" - cr.execute("select count(id) from survey_response_answer sra where sra.answer_id = %s", (ans.id,)) - tot_res = cr.fetchone()[0] - cr.execute("select count(id) ,sra.column_id from survey_response_answer sra where sra.answer_id=%s group by sra.column_id", (ans.id,)) - calc_res = cr.dictfetchall() - for mat_col in range(1, len(matrix_ans)): - percantage = 0.0 - cal_count = 0 - for cal in calc_res: - if cal['column_id'] == matrix_ans[mat_col][0]: - cal_count = cal['count'] - if tot_res: - percantage = round(float(cal_count)*100 / tot_res,2) - if percantage: - rml += """""" + tools.ustr(percantage) +"% (" + tools.ustr(cal_count) + """)""" - else: - rml += """""" + tools.ustr(percantage) +"% (" + tools.ustr(cal_count) + """)""" - rml += """""" + tools.ustr(tot_res) + """ - """ - rml += """""" +# for ans in que.answer_choice_ids: +# rml += """""" + to_xml(tools.ustr(ans.answer)) + """""" +# cr.execute("select count(id) from survey_response_answer sra where sra.answer_id = %s", (ans.id,)) +# tot_res = cr.fetchone()[0] +# cr.execute("select count(id) ,sra.column_id from survey_response_answer sra where sra.answer_id=%s group by sra.column_id", (ans.id,)) +# calc_res = cr.dictfetchall() +# for mat_col in range(1, len(matrix_ans)): +# percantage = 0.0 +# cal_count = 0 +# for cal in calc_res: +# if cal['column_id'] == matrix_ans[mat_col][0]: +# cal_count = cal['count'] +# if tot_res: +# percantage = round(float(cal_count)*100 / tot_res,2) +# if percantage: +# rml += """""" + tools.ustr(percantage) +"% (" + tools.ustr(cal_count) + """)""" +# else: +# rml += """""" + tools.ustr(percantage) +"% (" + tools.ustr(cal_count) + """)""" +# rml += """""" + tools.ustr(tot_res) + """ +# """ +# rml += """""" - if que.is_comment_require: - 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)) + """ - """ + tools.ustr(tot_res) + """""" +# if que.is_comment_require: +# 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)) + """ +# """ + tools.ustr(tot_res) + """""" - elif que.type in['multiple_choice_only_one_ans', 'multiple_choice_multiple_ans', 'multiple_textboxes','date_and_time','date','multiple_textboxes_diff_type']: - rml += """""" - rml += """ - - Answer Percentage - Answer Count - """ +# elif que.type in['multiple_choice_only_one_ans', 'multiple_choice_multiple_ans', 'multiple_textboxes','date_and_time','date','multiple_textboxes_diff_type']: +# rml += """""" +# rml += """ +# +# Answer Percentage +# Answer Count +# """ - for ans in que.answer_choice_ids: - progress = ans.average * 7 / 100 - rml += """""" + to_xml(tools.ustr(ans.answer)) + """ - - - - - """ - if progress: - rml += """ - """ - rml += """ - - - """ + tools.ustr(ans.average) + """% - - """ + tools.ustr(ans.response) + """""" - rml += """""" +# for ans in que.answer_choice_ids: +# progress = ans.average * 7 / 100 +# rml += """""" + to_xml(tools.ustr(ans.answer)) + """ +# +# +# +# +# """ +# if progress: +# rml += """ +# """ +# rml += """ +# +# +# """ + tools.ustr(ans.average) + """% +# +# """ + tools.ustr(ans.response) + """""" +# 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: - 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)) + """ - """ + tools.ustr(tot_res) + """""" +# 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: +# 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)) + """ +# """ + tools.ustr(tot_res) + """""" - elif que.type in['single_textbox']: - cr.execute("select count(id) from survey_response_line where question_id = %s and single_text!=''",(que.id,)) - rml += """ - - - Answer Count - - - """ + tools.ustr(cr.fetchone()[0]) + """ - """ +# elif que.type in['single_textbox']: +# cr.execute("select count(id) from survey_response_line where question_id = %s and single_text!=''",(que.id,)) +# rml += """ +# +# +# Answer Count +# +# +# """ + tools.ustr(cr.fetchone()[0]) + """ +# """ - elif que.type in['comment']: - cr.execute("select count(id) from survey_response_line where question_id = %s and comment !=''", (que.id,)) - rml += """ - - - Answer Count - - - """ + tools.ustr(cr.fetchone()[0]) + """ - """ +# elif que.type in['comment']: +# cr.execute("select count(id) from survey_response_line where question_id = %s and comment !=''", (que.id,)) +# rml += """ +# +# +# Answer Count +# +# +# """ + tools.ustr(cr.fetchone()[0]) + """ +# """ - elif que.type in['rating_scale']: - cols_widhts.append(200) - for col in range(0,len(que.column_heading_ids) + 2): - cols_widhts.append(float(300 / (len(que.column_heading_ids) + 2))) - colWidths = ",".join(map(tools.ustr, cols_widhts)) - matrix_ans = [(0,'')] +# elif que.type in['rating_scale']: +# cols_widhts.append(200) +# for col in range(0,len(que.column_heading_ids) + 2): +# cols_widhts.append(float(300 / (len(que.column_heading_ids) + 2))) +# colWidths = ",".join(map(tools.ustr, cols_widhts)) +# matrix_ans = [(0,'')] - for col in que.column_heading_ids: - if col.title not in matrix_ans: - matrix_ans.append((col.id,col.title)) - rml += """""" - for mat_col in range(0,len(matrix_ans)): - rml += """""" + to_xml(tools.ustr(matrix_ans[mat_col][1])) + """""" - rml += """Rating Average - Answer Count - """ +# for col in que.column_heading_ids: +# if col.title not in matrix_ans: +# matrix_ans.append((col.id,col.title)) +# rml += """""" +# for mat_col in range(0,len(matrix_ans)): +# rml += """""" + to_xml(tools.ustr(matrix_ans[mat_col][1])) + """""" +# rml += """Rating Average +# Answer Count +# """ - for ans in que.answer_choice_ids: - rml += """""" + to_xml(tools.ustr(ans.answer)) + """""" - res_count = 0 - rating_weight_sum = 0 - for mat_col in range(1, len(matrix_ans)): - cr.execute("select count(sra.answer_id) from survey_response_line sr, survey_response_answer sra\ - where sr.id = sra.response_line_id and sra.answer_id = %s and sra.column_id ='%s'", (ans.id,matrix_ans[mat_col][0])) - tot_res = cr.fetchone()[0] - 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_line_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])) - col_weight = cr.fetchone() +# for ans in que.answer_choice_ids: +# rml += """""" + to_xml(tools.ustr(ans.answer)) + """""" +# res_count = 0 +# rating_weight_sum = 0 +# for mat_col in range(1, len(matrix_ans)): +# cr.execute("select count(sra.answer_id) from survey_response_line sr, survey_response_answer sra\ +# where sr.id = sra.response_line_id and sra.answer_id = %s and sra.column_id ='%s'", (ans.id,matrix_ans[mat_col][0])) +# tot_res = cr.fetchone()[0] +# 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_line_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])) +# col_weight = cr.fetchone() - if not col_weight: - col_weight= (0,0) - elif not col_weight[1]: - col_weight = (col_weight[0],0) - res_count = col_weight[0] +# if not col_weight: +# col_weight= (0,0) +# elif not col_weight[1]: +# col_weight = (col_weight[0],0) +# res_count = col_weight[0] - if tot_res and res_count: - rating_weight_sum += int(col_weight[1]) * tot_res - tot_per = round((float(tot_res) * 100) / int(res_count), 2) - else: - tot_per = 0.0 - if tot_res: - rml += """""" + tools.ustr(tot_per) + "%(" + tools.ustr(tot_res) + """)""" - else: - rml += """""" + tools.ustr(tot_per)+"%(" + tools.ustr(tot_res) + """)""" +# if tot_res and res_count: +# rating_weight_sum += int(col_weight[1]) * tot_res +# tot_per = round((float(tot_res) * 100) / int(res_count), 2) +# else: +# tot_per = 0.0 +# if tot_res: +# rml += """""" + tools.ustr(tot_per) + "%(" + tools.ustr(tot_res) + """)""" +# else: +# rml += """""" + tools.ustr(tot_per)+"%(" + tools.ustr(tot_res) + """)""" - percantage = 0.00 - if res_count: - percantage = round((float(rating_weight_sum)/res_count), 2) - rml += """""" + tools.ustr(percantage) + """ - """ + tools.ustr(res_count) + """""" - rml += """""" +# percantage = 0.00 +# if res_count: +# percantage = round((float(rating_weight_sum)/res_count), 2) +# rml += """""" + tools.ustr(percantage) + """ +# """ + tools.ustr(res_count) + """""" +# rml += """""" - elif que.type in['numerical_textboxes']: - rml += """ - - - - Answer Average - Answer Total - Answer Count - """ - for ans in que.answer_choice_ids: - cr.execute("select answer from survey_response_answer where answer_id=%s group by answer", (ans.id,)) - tot_res = cr.dictfetchall() - total = 0 - for tot in tot_res: - total += int(tot['answer']) - per = 0.00 +# elif que.type in['numerical_textboxes']: +# rml += """ +# +# +# +# Answer Average +# Answer Total +# Answer Count +# """ +# for ans in que.answer_choice_ids: +# cr.execute("select answer from survey_response_answer where answer_id=%s group by answer", (ans.id,)) +# tot_res = cr.dictfetchall() +# total = 0 +# for tot in tot_res: +# total += int(tot['answer']) +# per = 0.00 - if len(tot_res): - per = round((float(total) / len(tot_res)),2) - rml+="""""" + to_xml(tools.ustr(ans.answer)) + """ - - """ + tools.ustr(per) +""" - """ + tools.ustr(total) + """ - """ + tools.ustr(len(tot_res)) + """""" - rml+="""""" +# if len(tot_res): +# per = round((float(total) / len(tot_res)),2) +# rml+="""""" + to_xml(tools.ustr(ans.answer)) + """ +# +# """ + tools.ustr(per) +""" +# """ + tools.ustr(total) + """ +# """ + tools.ustr(len(tot_res)) + """""" +# rml+="""""" - rml +=""" - - - Answered Question - """ + tools.ustr(que.tot_resp) + """ - - - - Skipped Questions - """ + tools.ustr(que.tot_resp - survey.tot_start_survey) + """ - - """ - rml += """""" +# rml +=""" +# +# +# Answered Question +# """ + tools.ustr(que.tot_resp) + """ +# +# +# +# Skipped Questions +# """ + tools.ustr(que.tot_resp - survey.tot_start_survey) + """ +# +# """ +# rml += """""" - rml += """""" - report_type = datas.get('report_type', 'pdf') - create_doc = self.generators[report_type] - self.internal_header=True - pdf = create_doc(rml, title=self.title) +# rml += """""" +# report_type = datas.get('report_type', 'pdf') +# create_doc = self.generators[report_type] +# self.internal_header=True +# pdf = create_doc(rml, title=self.title) - return (pdf, report_type) +# return (pdf, report_type) -survey_analysis('report.survey.analysis', 'survey','','') +# survey_analysis('report.survey.analysis', 'survey','','') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/survey/report/survey_browse_response.py b/addons/survey/report/survey_browse_response.py index a2c13cedceb..7e117cb6a21 100644 --- a/addons/survey/report/survey_browse_response.py +++ b/addons/survey/report/survey_browse_response.py @@ -1,537 +1,537 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved -# $Id$ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# # -*- encoding: utf-8 -*- +# ############################################################################## +# # +# # OpenERP, Open Source Management Solution +# # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# # $Id$ +# # +# # This program is free software: you can redistribute it and/or modify +# # it under the terms of the GNU Affero General Public License as published by +# # the Free Software Foundation, either version 3 of the License, or +# # (at your option) any later version. +# # +# # This program is distributed in the hope that it will be useful, +# # but WITHOUT ANY WARRANTY; without even the implied warranty of +# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# # GNU Affero General Public License for more details. +# # +# # You should have received a copy of the GNU Affero General Public License +# # along with this program. If not, see . +# # +# ############################################################################## -import time +# import time -import openerp -from openerp import tools -from openerp.report import report_sxw -from openerp.report.interface import report_rml -from openerp.tools import to_xml +# import openerp +# from openerp import tools +# from openerp.report import report_sxw +# from openerp.report.interface import report_rml +# from openerp.tools import to_xml -class survey_browse_response(report_rml): - def create(self, cr, uid, ids, datas, context): - _divide_columns_for_matrix = 0.7 - _display_ans_in_rows = 5 - _pageSize = ('29.7cm','21.1cm') +# class survey_browse_response(report_rml): +# def create(self, cr, uid, ids, datas, context): +# _divide_columns_for_matrix = 0.7 +# _display_ans_in_rows = 5 +# _pageSize = ('29.7cm','21.1cm') - registry = openerp.registry(cr.dbname) +# registry = openerp.registry(cr.dbname) - if datas.has_key('form') and datas['form'].get('orientation','') == 'vertical': - if datas['form'].get('paper_size','') == 'letter': - _pageSize = ('21.6cm','27.9cm') - elif datas['form'].get('paper_size','') == 'legal': - _pageSize = ('21.6cm','35.6cm') - elif datas['form'].get('paper_size','') == 'a4': - _pageSize = ('21.1cm','29.7cm') +# if datas.has_key('form') and datas['form'].get('orientation','') == 'vertical': +# if datas['form'].get('paper_size','') == 'letter': +# _pageSize = ('21.6cm','27.9cm') +# elif datas['form'].get('paper_size','') == 'legal': +# _pageSize = ('21.6cm','35.6cm') +# elif datas['form'].get('paper_size','') == 'a4': +# _pageSize = ('21.1cm','29.7cm') - elif datas.has_key('form') and datas['form'].get('orientation',False) == 'horizontal': - if datas['form'].get('paper_size','') == 'letter': - _pageSize = ('27.9cm','21.6cm') - elif datas['form'].get('paper_size','') == 'legal': - _pageSize = ('35.6cm','21.6cm') - elif datas['form'].get('paper_size') == 'a4': - _pageSize = ('29.7cm','21.1cm') +# elif datas.has_key('form') and datas['form'].get('orientation',False) == 'horizontal': +# if datas['form'].get('paper_size','') == 'letter': +# _pageSize = ('27.9cm','21.6cm') +# elif datas['form'].get('paper_size','') == 'legal': +# _pageSize = ('35.6cm','21.6cm') +# elif datas['form'].get('paper_size') == 'a4': +# _pageSize = ('29.7cm','21.1cm') - _frame_width = tools.ustr(_pageSize[0]) - _frame_height = tools.ustr(float(_pageSize[1].replace('cm','')) - float(1.90))+'cm' - _tbl_widths = tools.ustr(float(_pageSize[0].replace('cm','')) - float(2.10))+'cm' - rml =""" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """ - surv_resp_obj = registry['survey.response'] - rml_obj=report_sxw.rml_parse(cr, uid, surv_resp_obj._name,context) - if datas.has_key('form') and datas['form'].has_key('response_ids'): - response_id = datas['form']['response_ids'] - elif context.has_key('response_id') and context['response_id']: - response_id = [int(context['response_id'][0])] - else: - response_id = surv_resp_obj.search(cr, uid, [('survey_id', 'in', ids)]) +# _frame_width = tools.ustr(_pageSize[0]) +# _frame_height = tools.ustr(float(_pageSize[1].replace('cm','')) - float(1.90))+'cm' +# _tbl_widths = tools.ustr(float(_pageSize[0].replace('cm','')) - float(2.10))+'cm' +# rml =""" +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# """ +# surv_resp_obj = registry['survey.response'] +# rml_obj=report_sxw.rml_parse(cr, uid, surv_resp_obj._name,context) +# if datas.has_key('form') and datas['form'].has_key('response_ids'): +# response_id = datas['form']['response_ids'] +# elif context.has_key('response_id') and context['response_id']: +# response_id = [int(context['response_id'][0])] +# else: +# response_id = surv_resp_obj.search(cr, uid, [('survey_id', 'in', ids)]) - surv_resp_line_obj = registry['survey.response.line'] - surv_obj = registry['survey'] +# surv_resp_line_obj = registry['survey.response.line'] +# surv_obj = registry['survey'] - for response in surv_resp_obj.browse(cr, uid, response_id): - for survey in surv_obj.browse(cr, uid, [response.survey_id.id]): - tbl_width = float(_tbl_widths.replace('cm', '')) - colwidth = "2.5cm,4.8cm," + str(tbl_width - 15.0) +"cm,3.2cm,4.5cm" - resp_create = tools.ustr(time.strftime('%d-%m-%Y %I:%M:%S %p', time.strptime(response.date_create.split('.')[0], '%Y-%m-%d %H:%M:%S'))) - rml += """ - - Print Date : - """ + to_xml(rml_obj.formatLang(time.strftime("%Y-%m-%d %H:%M:%S"),date_time=True)) + """ - - Answered by : - """ + to_xml(response.partner_id.name or '') + """ - - - - - - Answer Date : - """ + to_xml(resp_create) + """ - - """ +# for response in surv_resp_obj.browse(cr, uid, response_id): +# for survey in surv_obj.browse(cr, uid, [response.survey_id.id]): +# tbl_width = float(_tbl_widths.replace('cm', '')) +# colwidth = "2.5cm,4.8cm," + str(tbl_width - 15.0) +"cm,3.2cm,4.5cm" +# resp_create = tools.ustr(time.strftime('%d-%m-%Y %I:%M:%S %p', time.strptime(response.date_create.split('.')[0], '%Y-%m-%d %H:%M:%S'))) +# rml += """ +# +# Print Date : +# """ + to_xml(rml_obj.formatLang(time.strftime("%Y-%m-%d %H:%M:%S"),date_time=True)) + """ +# +# Answered by : +# """ + to_xml(response.partner_id.name or '') + """ +# +# +# +# +# +# Answer Date : +# """ + to_xml(resp_create) + """ +# +# """ - status = "Not Finished" - if response.state == "done": status = "Finished" - colwidth = str(tbl_width - 7) + "cm," - colwidth += "7cm" - rml += """ - - """ + to_xml(tools.ustr(survey.title)) + """ - Status :- """ + to_xml(tools.ustr(status)) + """ - - """ +# status = "Not Finished" +# if response.state == "done": status = "Finished" +# colwidth = str(tbl_width - 7) + "cm," +# colwidth += "7cm" +# rml += """ +# +# """ + to_xml(tools.ustr(survey.title)) + """ +# Status :- """ + to_xml(tools.ustr(status)) + """ +# +# """ - if survey.note: - rml += """ - """ + to_xml(tools.ustr(survey.note or '')) + """ - """ +# if survey.note: +# rml += """ +# """ + to_xml(tools.ustr(survey.note or '')) + """ +# """ - for page in survey.page_ids: - rml += """ - Page :- """ + to_xml(tools.ustr(page.title or '')) + """ - """ - if page.note: - rml += """ - - """ + to_xml(tools.ustr(page.note or '')) + """ - """ +# for page in survey.page_ids: +# rml += """ +# Page :- """ + to_xml(tools.ustr(page.title or '')) + """ +# """ +# if page.note: +# rml += """ +# +# """ + to_xml(tools.ustr(page.note or '')) + """ +# """ - for que in page.question_ids: - rml += """ - - """ + to_xml(to_xml(que.question)) + """ - """ +# for que in page.question_ids: +# rml += """ +# +# """ + to_xml(to_xml(que.question)) + """ +# """ - answer = surv_resp_line_obj.browse(cr ,uid, surv_resp_line_obj.search(cr, uid, [('question_id', '=', que.id),('response_id', '=', response.id)])) - if que.type in ['descriptive_text']: - rml +=""" - """ + to_xml(tools.ustr(que.descriptive_text)) + """ - """ +# answer = surv_resp_line_obj.browse(cr ,uid, surv_resp_line_obj.search(cr, uid, [('question_id', '=', que.id),('response_id', '=', response.id)])) +# if que.type in ['descriptive_text']: +# rml +=""" +# """ + to_xml(tools.ustr(que.descriptive_text)) + """ +# """ - elif que.type in ['table']: - if len(answer) and answer[0].state == "done": - col_heading = registry['survey.tbl.column.heading'] - cols_widhts = [] - tbl_width = float(_tbl_widths.replace('cm', '')) - for i in range(0, len(que.column_heading_ids)): - cols_widhts.append(tbl_width / float(len(que.column_heading_ids))) - colWidths = "cm,".join(map(tools.ustr, cols_widhts)) - colWidths = colWidths + 'cm' - matrix_ans = [] - rml +="""""" +# elif que.type in ['table']: +# if len(answer) and answer[0].state == "done": +# col_heading = registry['survey.tbl.column.heading'] +# cols_widhts = [] +# tbl_width = float(_tbl_widths.replace('cm', '')) +# for i in range(0, len(que.column_heading_ids)): +# cols_widhts.append(tbl_width / float(len(que.column_heading_ids))) +# colWidths = "cm,".join(map(tools.ustr, cols_widhts)) +# colWidths = colWidths + 'cm' +# matrix_ans = [] +# rml +="""""" - for col in que.column_heading_ids: - if col.title not in matrix_ans: - matrix_ans.append(col.title) - rml += """ """ + to_xml(tools.ustr(col.title)) +"""""" - rml += """""" - i = 0 +# for col in que.column_heading_ids: +# if col.title not in matrix_ans: +# matrix_ans.append(col.title) +# rml += """ """ + to_xml(tools.ustr(col.title)) +"""""" +# rml += """""" +# i = 0 - for row in range(0, que.no_of_rows): - if i%2 != 0: - style = 'tbl_white' - else: - style = 'tbl_gainsboro' - i +=1 - rml += """""" - table_data = col_heading.browse(cr, uid, col_heading.search(cr, uid, [('response_table_id', '=', answer[0].id), ('name', '=', row)])) - for column in matrix_ans: - value = False - for col in table_data: - if column == col.column_id.title: - value = col.value - if value: - rml += """ """ + to_xml(tools.ustr(value)) +"""""" - else: - rml += """ """ - rml += """""" +# for row in range(0, que.no_of_rows): +# if i%2 != 0: +# style = 'tbl_white' +# else: +# style = 'tbl_gainsboro' +# i +=1 +# rml += """""" +# table_data = col_heading.browse(cr, uid, col_heading.search(cr, uid, [('response_table_id', '=', answer[0].id), ('name', '=', row)])) +# for column in matrix_ans: +# value = False +# for col in table_data: +# if column == col.column_id.title: +# value = col.value +# if value: +# rml += """ """ + to_xml(tools.ustr(value)) +"""""" +# else: +# rml += """ """ +# rml += """""" - else: - rml +=""" - No Answer - """ +# else: +# rml +=""" +# No Answer +# """ - elif que.type in ['multiple_choice_only_one_ans','multiple_choice_multiple_ans']: - if len(answer) and answer[0].state == "done": - ans_list = [] - for ans in answer[0].response_answer_ids: - ans_list.append(to_xml(tools.ustr(ans.answer_id.answer))) - answer_choice=[] +# elif que.type in ['multiple_choice_only_one_ans','multiple_choice_multiple_ans']: +# if len(answer) and answer[0].state == "done": +# ans_list = [] +# for ans in answer[0].response_answer_ids: +# ans_list.append(to_xml(tools.ustr(ans.answer_id.answer))) +# answer_choice=[] - for ans in que['answer_choice_ids']: - answer_choice.append(to_xml(tools.ustr((ans.answer)))) +# for ans in que['answer_choice_ids']: +# answer_choice.append(to_xml(tools.ustr((ans.answer)))) - def divide_list(lst, n): - return [lst[i::n] for i in range(n)] +# def divide_list(lst, n): +# return [lst[i::n] for i in range(n)] - divide_list = divide_list(answer_choice,_display_ans_in_rows) - for lst in divide_list: - if que.type == 'multiple_choice_multiple_ans': - if len(lst) <> 0 and len(lst) <> int(round(float(len(answer_choice)) / _display_ans_in_rows, 0)): - lst.append('') - if not lst: - del divide_list[divide_list.index(lst):] +# divide_list = divide_list(answer_choice,_display_ans_in_rows) +# for lst in divide_list: +# if que.type == 'multiple_choice_multiple_ans': +# if len(lst) <> 0 and len(lst) <> int(round(float(len(answer_choice)) / _display_ans_in_rows, 0)): +# lst.append('') +# if not lst: +# del divide_list[divide_list.index(lst):] - for divide in divide_list: - a = _divide_columns_for_matrix * len(divide) - b = float(_tbl_widths.replace('cm', '')) - float(a) - cols_widhts = [] - for div in range(0, len(divide)): - cols_widhts.append(float(a / len(divide))) - cols_widhts.append(float(b / len(divide))) - colWidths = "cm,".join(map(tools.ustr, cols_widhts)) - colWidths = colWidths +'cm' - rml += """""" +# for divide in divide_list: +# a = _divide_columns_for_matrix * len(divide) +# b = float(_tbl_widths.replace('cm', '')) - float(a) +# cols_widhts = [] +# for div in range(0, len(divide)): +# cols_widhts.append(float(a / len(divide))) +# cols_widhts.append(float(b / len(divide))) +# colWidths = "cm,".join(map(tools.ustr, cols_widhts)) +# colWidths = colWidths +'cm' +# rml += """""" - for div in range(0, len(divide)): - if divide[div] != '': - if que.type == 'multiple_choice_multiple_ans': - if divide[div] in ans_list: - rml += """ - - - - - """ + divide[div] + """""" - else: - rml+=""" - - - """ + divide[div] + """""" - else: - if divide[div] in ans_list: - rml += """ - - - - - """ + divide[div] + """""" - else: - rml += """ - - - - - """ + divide[div] + """""" - else: - rml += """""" - rml += """""" +# for div in range(0, len(divide)): +# if divide[div] != '': +# if que.type == 'multiple_choice_multiple_ans': +# if divide[div] in ans_list: +# rml += """ +# +# +# +# +# """ + divide[div] + """""" +# else: +# rml+=""" +# +# +# """ + divide[div] + """""" +# else: +# if divide[div] in ans_list: +# rml += """ +# +# +# +# +# """ + divide[div] + """""" +# else: +# rml += """ +# +# +# +# +# """ + divide[div] + """""" +# else: +# rml += """""" +# rml += """""" - if que.is_comment_require and answer[0].comment: - rml += """ - """ + to_xml(tools.ustr(answer[0].comment)) + """""" - else: - rml += """ - No Answer - """ +# if que.is_comment_require and answer[0].comment: +# rml += """ +# """ + to_xml(tools.ustr(answer[0].comment)) + """""" +# else: +# rml += """ +# No Answer +# """ - elif que.type in ['multiple_textboxes_diff_type','multiple_textboxes','date','date_and_time','numerical_textboxes','multiple_textboxes_diff_type']: - if len(answer) and answer[0].state == "done": - cols_widhts = [] - cols_widhts.append(float(_tbl_widths.replace('cm',''))/2) - cols_widhts.append(float(_tbl_widths.replace('cm',''))/2) - colWidths = "cm,".join(map(tools.ustr, cols_widhts)) - colWidths = tools.ustr(colWidths) + 'cm' - answer_list = {} +# elif que.type in ['multiple_textboxes_diff_type','multiple_textboxes','date','date_and_time','numerical_textboxes','multiple_textboxes_diff_type']: +# if len(answer) and answer[0].state == "done": +# cols_widhts = [] +# cols_widhts.append(float(_tbl_widths.replace('cm',''))/2) +# cols_widhts.append(float(_tbl_widths.replace('cm',''))/2) +# colWidths = "cm,".join(map(tools.ustr, cols_widhts)) +# colWidths = tools.ustr(colWidths) + 'cm' +# answer_list = {} - for ans in answer[0].response_answer_ids: - answer_list[ans.answer_id.answer] = ans.answer - for que_ans in que['answer_choice_ids']: - if que_ans.answer in answer_list: - rml += """ - """ + to_xml(tools.ustr(que_ans.answer)) + """ - """ + to_xml(tools.ustr(answer_list[que_ans.answer])) + """ - """ - else: - rml += """ - """ + to_xml(tools.ustr(que_ans.answer)) + """ - - """ - else: - rml += """ - No Answer - """ +# for ans in answer[0].response_answer_ids: +# answer_list[ans.answer_id.answer] = ans.answer +# for que_ans in que['answer_choice_ids']: +# if que_ans.answer in answer_list: +# rml += """ +# """ + to_xml(tools.ustr(que_ans.answer)) + """ +# """ + to_xml(tools.ustr(answer_list[que_ans.answer])) + """ +# """ +# else: +# rml += """ +# """ + to_xml(tools.ustr(que_ans.answer)) + """ +# +# """ +# else: +# rml += """ +# No Answer +# """ - elif que.type in ['single_textbox']: - if len(answer) and answer[0].state == "done": - rml += """ - """ + to_xml(tools.ustr(answer[0].single_text)) + """ - """ - else: - rml += """ - No Answer - """ +# elif que.type in ['single_textbox']: +# if len(answer) and answer[0].state == "done": +# rml += """ +# """ + to_xml(tools.ustr(answer[0].single_text)) + """ +# """ +# else: +# rml += """ +# No Answer +# """ - elif que.type in ['comment']: - if len(answer) and answer[0].state == "done": - rml += """ - """ + to_xml(tools.ustr(answer[0].comment)) + """ - """ - else: - rml += """ - No Answer - """ +# elif que.type in ['comment']: +# if len(answer) and answer[0].state == "done": +# rml += """ +# """ + to_xml(tools.ustr(answer[0].comment)) + """ +# """ +# else: +# rml += """ +# No Answer +# """ - elif que.type in ['matrix_of_choices_only_one_ans','matrix_of_choices_only_multi_ans', 'rating_scale']: - if len(answer) and answer[0].state == "done": - if que.type in ['matrix_of_choices_only_one_ans', 'rating_scale'] and que.comment_column: - pass - cols_widhts = [] - if len(que.column_heading_ids): - cols_widhts.append(float(_tbl_widths.replace('cm','')) / float(2.0)) - for col in que.column_heading_ids: - cols_widhts.append(float((float(_tbl_widths.replace('cm','')) / float(2.0)) / len(que.column_heading_ids))) - else: - cols_widhts.append(float(_tbl_widths.replace('cm',''))) +# elif que.type in ['matrix_of_choices_only_one_ans','matrix_of_choices_only_multi_ans', 'rating_scale']: +# if len(answer) and answer[0].state == "done": +# if que.type in ['matrix_of_choices_only_one_ans', 'rating_scale'] and que.comment_column: +# pass +# cols_widhts = [] +# if len(que.column_heading_ids): +# cols_widhts.append(float(_tbl_widths.replace('cm','')) / float(2.0)) +# for col in que.column_heading_ids: +# cols_widhts.append(float((float(_tbl_widths.replace('cm','')) / float(2.0)) / len(que.column_heading_ids))) +# else: +# cols_widhts.append(float(_tbl_widths.replace('cm',''))) - tmp = 0.0 - sum = 0.0 - i = 0 - 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 - tmp = cols_widhts[i] - sum += col - i += 1 - cols_widhts.append(round(tmp, 2)) - colWidths = "cm,".join(map(tools.ustr, cols_widhts)) - colWidths = colWidths + 'cm' - matrix_ans = [(0, ''),] +# tmp = 0.0 +# sum = 0.0 +# i = 0 +# 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 +# tmp = cols_widhts[i] +# sum += col +# i += 1 +# cols_widhts.append(round(tmp, 2)) +# colWidths = "cm,".join(map(tools.ustr, cols_widhts)) +# colWidths = colWidths + 'cm' +# matrix_ans = [(0, ''),] - for col in que.column_heading_ids: - if col.title not in matrix_ans: - matrix_ans.append((col.id, col.title)) - len_matrix = len(matrix_ans) - if que.type in ['matrix_of_choices_only_one_ans', 'rating_scale'] and que.comment_column: - matrix_ans.append((0,que.column_name)) - rml += """""" +# for col in que.column_heading_ids: +# if col.title not in matrix_ans: +# matrix_ans.append((col.id, col.title)) +# len_matrix = len(matrix_ans) +# if que.type in ['matrix_of_choices_only_one_ans', 'rating_scale'] and que.comment_column: +# matrix_ans.append((0,que.column_name)) +# rml += """""" - for mat_col in range(0, len(matrix_ans)): - rml += """""" + to_xml(tools.ustr(matrix_ans[mat_col][1])) + """""" - rml += """""" - rml += """""" - i = 0 +# for mat_col in range(0, len(matrix_ans)): +# rml += """""" + to_xml(tools.ustr(matrix_ans[mat_col][1])) + """""" +# rml += """""" +# rml += """""" +# i = 0 - for ans in que.answer_choice_ids: - if i%2 != 0: - style = 'ans_tbl_white' - else: - style = 'ans_tbl_gainsboro' - i += 1 - rml += """ - """ + to_xml(tools.ustr(ans.answer)) + """""" - comment_value = "" - for mat_col in range(1, len_matrix): - value = """""" - for res_ans in answer[0].response_answer_ids: - if res_ans.answer_id.id == ans.id and res_ans.column_id.id == matrix_ans[mat_col][0]: - comment_value = to_xml(tools.ustr(res_ans.comment_field)) - if que.type in ['matrix_of_choices_only_one_ans', 'rating_scale']: - value = """ - - - - """ - elif que.type in ['matrix_of_choices_only_multi_ans']: - value = """ - - - - - """ - break - else: - if que.type in ['matrix_of_choices_only_one_ans','rating_scale']: - value = """ - - """ - elif que.type in ['matrix_of_choices_only_multi_ans']: - value = """ - - """ - rml+= """""" + value + """""" - 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 += """""" +# for ans in que.answer_choice_ids: +# if i%2 != 0: +# style = 'ans_tbl_white' +# else: +# style = 'ans_tbl_gainsboro' +# i += 1 +# rml += """ +# """ + to_xml(tools.ustr(ans.answer)) + """""" +# comment_value = "" +# for mat_col in range(1, len_matrix): +# value = """""" +# for res_ans in answer[0].response_answer_ids: +# if res_ans.answer_id.id == ans.id and res_ans.column_id.id == matrix_ans[mat_col][0]: +# comment_value = to_xml(tools.ustr(res_ans.comment_field)) +# if que.type in ['matrix_of_choices_only_one_ans', 'rating_scale']: +# value = """ +# +# +# +# """ +# elif que.type in ['matrix_of_choices_only_multi_ans']: +# value = """ +# +# +# +# +# """ +# break +# else: +# if que.type in ['matrix_of_choices_only_one_ans','rating_scale']: +# value = """ +# +# """ +# elif que.type in ['matrix_of_choices_only_multi_ans']: +# value = """ +# +# """ +# rml+= """""" + value + """""" +# 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.is_comment_require: - rml += """ - """ + to_xml(tools.ustr(answer[0].comment or '')) + """""" - else: - rml += """ - No Answer - """ +# if que.is_comment_require: +# rml += """ +# """ + to_xml(tools.ustr(answer[0].comment or '')) + """""" +# else: +# rml += """ +# No Answer +# """ - if datas.has_key('form') and not datas['form']['without_pagebreak']: - rml += """""" - elif not datas.has_key('form'): - rml += """""" - else: - rml += """""" +# if datas.has_key('form') and not datas['form']['without_pagebreak']: +# rml += """""" +# elif not datas.has_key('form'): +# rml += """""" +# else: +# rml += """""" - rml += """""" - report_type = datas.get('report_type', 'pdf') - create_doc = self.generators[report_type] - pdf = create_doc(rml, title=self.title) - return (pdf, report_type) +# rml += """""" +# report_type = datas.get('report_type', 'pdf') +# create_doc = self.generators[report_type] +# pdf = create_doc(rml, title=self.title) +# return (pdf, report_type) -survey_browse_response('report.survey.browse.response', 'survey','','') +# survey_browse_response('report.survey.browse.response', 'survey','','') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/survey/report/survey_form.py b/addons/survey/report/survey_form.py index 4b05e5b6542..1934c599ace 100644 --- a/addons/survey/report/survey_form.py +++ b/addons/survey/report/survey_form.py @@ -1,416 +1,416 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved -# $Id$ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# # -*- encoding: utf-8 -*- +# ############################################################################## +# # +# # OpenERP, Open Source Management Solution +# # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# # $Id$ +# # +# # This program is free software: you can redistribute it and/or modify +# # it under the terms of the GNU Affero General Public License as published by +# # the Free Software Foundation, either version 3 of the License, or +# # (at your option) any later version. +# # +# # This program is distributed in the hope that it will be useful, +# # but WITHOUT ANY WARRANTY; without even the implied warranty of +# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# # GNU Affero General Public License for more details. +# # +# # You should have received a copy of the GNU Affero General Public License +# # along with this program. If not, see . +# # +# ############################################################################## -import openerp -from openerp import tools -from openerp.report.interface import report_rml -from openerp.tools import to_xml -import lxml -from lxml.html.clean import Cleaner -cleaner = Cleaner(style=True, links=False, add_nofollow=True, page_structure=True, safe_attrs_only=True) +# import openerp +# from openerp import tools +# from openerp.report.interface import report_rml +# from openerp.tools import to_xml +# import lxml +# from lxml.html.clean import Cleaner +# cleaner = Cleaner(style=True, links=False, add_nofollow=True, page_structure=True, safe_attrs_only=True) -class survey_form(report_rml): - def create(self, cr, uid, ids, datas, context): - _divide_columns_for_matrix = 0.7 - _display_ans_in_rows = 5 - _pageSize = ('29.7cm','21.1cm') - if datas.has_key('form') and datas['form'].get('orientation','') == 'vertical': - if datas['form'].get('paper_size','') == 'letter': - _pageSize = ('21.6cm','27.9cm') - elif datas['form'].get('paper_size','') == 'legal': - _pageSize = ('21.6cm','35.6cm') - elif datas['form'].get('paper_size','') == 'a4': - _pageSize = ('21.1cm','29.7cm') - elif datas.has_key('form') and datas['form'].get('orientation','') == 'horizontal': - if datas['form'].get('paper_size','') == 'letter': - _pageSize = ('27.9cm','21.6cm') - elif datas['form'].get('paper_size','') == 'legal': - _pageSize = ('35.6cm','21.6cm') - elif datas['form'].get('paper_size','') == 'a4': - _pageSize = ('29.7cm','21.1cm') +# class survey_form(report_rml): +# def create(self, cr, uid, ids, datas, context): +# _divide_columns_for_matrix = 0.7 +# _display_ans_in_rows = 5 +# _pageSize = ('29.7cm','21.1cm') +# if datas.has_key('form') and datas['form'].get('orientation','') == 'vertical': +# if datas['form'].get('paper_size','') == 'letter': +# _pageSize = ('21.6cm','27.9cm') +# elif datas['form'].get('paper_size','') == 'legal': +# _pageSize = ('21.6cm','35.6cm') +# elif datas['form'].get('paper_size','') == 'a4': +# _pageSize = ('21.1cm','29.7cm') +# elif datas.has_key('form') and datas['form'].get('orientation','') == 'horizontal': +# if datas['form'].get('paper_size','') == 'letter': +# _pageSize = ('27.9cm','21.6cm') +# elif datas['form'].get('paper_size','') == 'legal': +# _pageSize = ('35.6cm','21.6cm') +# elif datas['form'].get('paper_size','') == 'a4': +# _pageSize = ('29.7cm','21.1cm') - _frame_width = tools.ustr(_pageSize[0]) - _frame_height = tools.ustr(float(_pageSize[1].replace('cm','')) - float(1.90))+'cm' - _tbl_widths = tools.ustr(float(_pageSize[0].replace('cm','')) - float(2.10))+'cm' +# _frame_width = tools.ustr(_pageSize[0]) +# _frame_height = tools.ustr(float(_pageSize[1].replace('cm','')) - float(1.90))+'cm' +# _tbl_widths = tools.ustr(float(_pageSize[0].replace('cm','')) - float(2.10))+'cm' - rml=""" - +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# """ +# surv_obj = openerp.registry(cr.dbname)['survey'] +# for survey in surv_obj.browse(cr,uid,ids): +# rml += """ +# +# """ + to_xml(tools.ustr(survey.title)) + """ +# """ +# if survey.note: +# rml += """ +# +# +# """ + to_xml(tools.ustr(survey.note)) + """ +# """ - seq = 0 - for page in survey.page_ids: - seq += 1 - rml += """ - - """+ tools.ustr(seq) + """. """ + to_xml(tools.ustr(page.title)) + """ - """ - if page.note: - rml += """ - """ + to_xml(tools.ustr(page.note or '')) + """ - """ +# seq = 0 +# for page in survey.page_ids: +# seq += 1 +# rml += """ +# +# """+ tools.ustr(seq) + """. """ + to_xml(tools.ustr(page.title)) + """ +# """ +# if page.note: +# rml += """ +# """ + to_xml(tools.ustr(page.note or '')) + """ +# """ - for que in page.question_ids: - cols_widhts = [] - rml += """ - - - """ + to_xml(tools.ustr(que.question)) + """ - - """ - if que.descriptive_text: - style = (que.type in ['descriptive_text']) and ' style="ans_tbl" ' or "" - descriptive_text = lxml.etree.tostring( - cleaner.clean_html( - lxml.html.fromstring(que.descriptive_text))) - rml += """ - - - - """ + descriptive_text + """ - - - """ - if que.type not in ['descriptive_text']: - rml += """""" +# for que in page.question_ids: +# cols_widhts = [] +# rml += """ +# +# +# """ + to_xml(tools.ustr(que.question)) + """ +# +# """ +# if que.descriptive_text: +# style = (que.type in ['descriptive_text']) and ' style="ans_tbl" ' or "" +# descriptive_text = lxml.etree.tostring( +# cleaner.clean_html( +# lxml.html.fromstring(que.descriptive_text))) +# rml += """ +# +# +# +# """ + descriptive_text + """ +# +# +# """ +# if que.type not in ['descriptive_text']: +# rml += """""" - if que.type in ['descriptive_text']: - continue +# if que.type in ['descriptive_text']: +# continue - elif que.type in ['multiple_choice_multiple_ans','multiple_choice_only_one_ans']: - answer = [] - for ans in que.answer_choice_ids: - answer.append(to_xml(tools.ustr((ans.answer)))) +# elif que.type in ['multiple_choice_multiple_ans','multiple_choice_only_one_ans']: +# answer = [] +# for ans in que.answer_choice_ids: +# answer.append(to_xml(tools.ustr((ans.answer)))) - def divide_list(lst, n): - return [lst[i::n] for i in range(n)] +# def divide_list(lst, n): +# return [lst[i::n] for i in range(n)] - divide_list = divide_list(answer,_display_ans_in_rows) - for lst in divide_list: - if que.type == 'multiple_choice_multiple_ans': - if len(lst)<>0 and len(lst)<>int(round(float(len(answer))/_display_ans_in_rows,0)): - lst.append('') - if not lst: - del divide_list[divide_list.index(lst):] - for divide in divide_list: - a = _divide_columns_for_matrix*len(divide) - b = float(_tbl_widths.replace('cm','')) - float(a) - cols_widhts = [] +# divide_list = divide_list(answer,_display_ans_in_rows) +# for lst in divide_list: +# if que.type == 'multiple_choice_multiple_ans': +# if len(lst)<>0 and len(lst)<>int(round(float(len(answer))/_display_ans_in_rows,0)): +# lst.append('') +# if not lst: +# del divide_list[divide_list.index(lst):] +# for divide in divide_list: +# a = _divide_columns_for_matrix*len(divide) +# b = float(_tbl_widths.replace('cm','')) - float(a) +# cols_widhts = [] - for div in range(0,len(divide)): - cols_widhts.append(float(a/len(divide))) - cols_widhts.append(float(b/len(divide))) - colWidths = "cm,".join(map(tools.ustr, cols_widhts)) - colWidths = colWidths +'cm' - rml+=""" - """ - for div in range(0,len(divide)): - if divide[div] != '': - if que.type == 'multiple_choice_multiple_ans': - rml += """ - - - - - - """ + divide[div] + """""" - else: - rml += """ - - - - - - """ + divide[div] + """""" - else: - rml += """ - - """ - rml += """ - """ +# for div in range(0,len(divide)): +# cols_widhts.append(float(a/len(divide))) +# cols_widhts.append(float(b/len(divide))) +# colWidths = "cm,".join(map(tools.ustr, cols_widhts)) +# colWidths = colWidths +'cm' +# rml+=""" +# """ +# for div in range(0,len(divide)): +# if divide[div] != '': +# if que.type == 'multiple_choice_multiple_ans': +# rml += """ +# +# +# +# +# +# """ + divide[div] + """""" +# else: +# rml += """ +# +# +# +# +# +# """ + divide[div] + """""" +# else: +# rml += """ +# +# """ +# rml += """ +# """ - elif que.type in ['matrix_of_choices_only_one_ans','rating_scale','matrix_of_choices_only_multi_ans']: - if len(que.column_heading_ids): - cols_widhts.append(float(_tbl_widths.replace('cm',''))/float(2.0)) - for col in que.column_heading_ids: - cols_widhts.append(float((float(_tbl_widths.replace('cm',''))/float(2.0))/len(que.column_heading_ids))) - else: - cols_widhts.append(float(_tbl_widths.replace('cm',''))) +# elif que.type in ['matrix_of_choices_only_one_ans','rating_scale','matrix_of_choices_only_multi_ans']: +# if len(que.column_heading_ids): +# cols_widhts.append(float(_tbl_widths.replace('cm',''))/float(2.0)) +# for col in que.column_heading_ids: +# cols_widhts.append(float((float(_tbl_widths.replace('cm',''))/float(2.0))/len(que.column_heading_ids))) +# else: +# cols_widhts.append(float(_tbl_widths.replace('cm',''))) - tmp = 0.0 - sum = 0.0 - i = 0 - if que.comment_column: - for col in cols_widhts: - if i == 0: - cols_widhts[i] = cols_widhts[i]/2.0 - tmp = cols_widhts[i] - sum += col - i += 1 - cols_widhts.append(round(tmp,2)) - colWidths = "cm,".join(map(tools.ustr, cols_widhts)) - colWidths = colWidths+'cm' - matrix_ans = ['',] +# tmp = 0.0 +# sum = 0.0 +# i = 0 +# if que.comment_column: +# for col in cols_widhts: +# if i == 0: +# cols_widhts[i] = cols_widhts[i]/2.0 +# tmp = cols_widhts[i] +# sum += col +# i += 1 +# cols_widhts.append(round(tmp,2)) +# colWidths = "cm,".join(map(tools.ustr, cols_widhts)) +# colWidths = colWidths+'cm' +# matrix_ans = ['',] - for col in que.column_heading_ids: - if col.title not in matrix_ans: - matrix_ans.append(col.title) - if que.comment_column: - matrix_ans.append(tools.ustr(que.column_name)) - rml+="""""" +# for col in que.column_heading_ids: +# if col.title not in matrix_ans: +# matrix_ans.append(col.title) +# if que.comment_column: +# matrix_ans.append(tools.ustr(que.column_name)) +# rml+="""""" - for mat_col in matrix_ans: - rml += """""" + to_xml(tools.ustr(mat_col)) + """""" - rml += """""" - i = 0 - for ans in que.answer_choice_ids: - if i%2 != 0: - style='ans_tbl_white' - else: - style='ans_tbl_gainsboro' - i += 1 - rml += """ - - """ + to_xml(tools.ustr(ans.answer)) + """""" - rec_width = float((sum-tmp)*10+100) - value = "" +# for mat_col in matrix_ans: +# rml += """""" + to_xml(tools.ustr(mat_col)) + """""" +# rml += """""" +# i = 0 +# for ans in que.answer_choice_ids: +# if i%2 != 0: +# style='ans_tbl_white' +# else: +# style='ans_tbl_gainsboro' +# i += 1 +# rml += """ +# +# """ + to_xml(tools.ustr(ans.answer)) + """""" +# rec_width = float((sum-tmp)*10+100) +# value = "" - if que.type in ['matrix_of_choices_only_one_ans','rating_scale']: - value = """ - """ - else: - value = """ - """ - for mat_col in range(1,len(matrix_ans)): - if matrix_ans[mat_col] == que.column_name: - if mat_col == 1: - rml += """ - """ + to_xml(tools.ustr(que.column_name)) + """""" - else: - rml += """""" - else: - rml += """""" + value + """""" - rml += """""" +# if que.type in ['matrix_of_choices_only_one_ans','rating_scale']: +# value = """ +# """ +# else: +# value = """ +# """ +# for mat_col in range(1,len(matrix_ans)): +# if matrix_ans[mat_col] == que.column_name: +# if mat_col == 1: +# rml += """ +# """ + to_xml(tools.ustr(que.column_name)) + """""" +# else: +# rml += """""" +# else: +# rml += """""" + value + """""" +# rml += """""" - elif que.type in ['multiple_textboxes', 'numerical_textboxes', 'date_and_time','date','multiple_textboxes_diff_type']: - cols_widhts.append(float(_tbl_widths.replace('cm',''))/2) - cols_widhts.append(float(_tbl_widths.replace('cm',''))/2) - colWidths = "cm,".join(map(tools.ustr, cols_widhts)) - colWidths = tools.ustr(colWidths) + 'cm' - for ans in que.answer_choice_ids: - rml += """ - - - """ + to_xml(tools.ustr(ans.answer)) + """ - - - - - - - """ +# elif que.type in ['multiple_textboxes', 'numerical_textboxes', 'date_and_time','date','multiple_textboxes_diff_type']: +# cols_widhts.append(float(_tbl_widths.replace('cm',''))/2) +# cols_widhts.append(float(_tbl_widths.replace('cm',''))/2) +# colWidths = "cm,".join(map(tools.ustr, cols_widhts)) +# colWidths = tools.ustr(colWidths) + 'cm' +# for ans in que.answer_choice_ids: +# rml += """ +# +# +# """ + to_xml(tools.ustr(ans.answer)) + """ +# +# +# +# +# +# +# """ - elif que.type in ['comment']: - cols_widhts.append(float(_tbl_widths.replace('cm',''))) - inner_Widths = [] - for width in cols_widhts: - inner_Widths.append(width - 0.6) +# elif que.type in ['comment']: +# cols_widhts.append(float(_tbl_widths.replace('cm',''))) +# inner_Widths = [] +# for width in cols_widhts: +# inner_Widths.append(width - 0.6) - colWidths = "cm,".join(map(tools.ustr, cols_widhts)) + 'cm' - InnerWidths = "cm,".join(map(tools.ustr, inner_Widths)) + 'cm' +# colWidths = "cm,".join(map(tools.ustr, cols_widhts)) + 'cm' +# InnerWidths = "cm,".join(map(tools.ustr, inner_Widths)) + 'cm' - rml += """ - - - - - - - - """ +# rml += """ +# +# +# +# +# +# +# +# """ - elif que.type in ['single_textbox']: - cols_widhts.append(float(_tbl_widths.replace('cm',''))) - inner_Widths = [] - for width in cols_widhts: - inner_Widths.append(width - 0.7) +# elif que.type in ['single_textbox']: +# cols_widhts.append(float(_tbl_widths.replace('cm',''))) +# inner_Widths = [] +# for width in cols_widhts: +# inner_Widths.append(width - 0.7) - colWidths = "cm,".join(map(tools.ustr, cols_widhts)) + 'cm' - InnerWidths = "cm,".join(map(tools.ustr, inner_Widths)) + 'cm' +# colWidths = "cm,".join(map(tools.ustr, cols_widhts)) + 'cm' +# InnerWidths = "cm,".join(map(tools.ustr, inner_Widths)) + 'cm' - rml += """ - - - - - - - - - """ +# rml += """ +# +# +# +# +# +# +# +# +# """ - elif que.type in ['table']: - tbl_width = float(_tbl_widths.replace('cm','')) - for i in range(0,len(que.column_heading_ids)): - cols_widhts.append(tbl_width/float(len(que.column_heading_ids))) - colWidths = "cm,".join(map(tools.ustr, cols_widhts)) - colWidths = colWidths+'cm' - rml += """""" - for col in que.column_heading_ids: - rml+="""""" + to_xml(tools.ustr(col.title)) + """""" - rml += """""" - i = 0 - for r in range(0,que.no_of_rows): - if i%2 != 0: - style = 'tbl_white' - else: - style = 'tbl_gainsboro' - i += 1 - rml += """""" - for c in que.column_heading_ids: - rml += """ - """ - rml += """""" +# elif que.type in ['table']: +# tbl_width = float(_tbl_widths.replace('cm','')) +# for i in range(0,len(que.column_heading_ids)): +# cols_widhts.append(tbl_width/float(len(que.column_heading_ids))) +# colWidths = "cm,".join(map(tools.ustr, cols_widhts)) +# colWidths = colWidths+'cm' +# rml += """""" +# for col in que.column_heading_ids: +# rml+="""""" + to_xml(tools.ustr(col.title)) + """""" +# rml += """""" +# i = 0 +# for r in range(0,que.no_of_rows): +# if i%2 != 0: +# style = 'tbl_white' +# else: +# style = 'tbl_gainsboro' +# i += 1 +# rml += """""" +# for c in que.column_heading_ids: +# rml += """ +# """ +# rml += """""" - if datas.has_key('form') and not datas['form']['without_pagebreak']: - rml += """""" - elif not datas.has_key('form'): - rml += """""" - else: - rml += """""" +# if datas.has_key('form') and not datas['form']['without_pagebreak']: +# rml += """""" +# elif not datas.has_key('form'): +# rml += """""" +# else: +# rml += """""" - rml += """""" - report_type = datas.get('report_type', 'pdf') - create_doc = self.generators[report_type] - pdf = create_doc(rml, title=self.title) - return (pdf, report_type) +# rml += """""" +# report_type = datas.get('report_type', 'pdf') +# create_doc = self.generators[report_type] +# pdf = create_doc(rml, title=self.title) +# return (pdf, report_type) -survey_form('report.survey.form', 'survey','','') +# survey_form('report.survey.form', 'survey','','') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: