diff --git a/addons/survey/report/survey_browse_response.py b/addons/survey/report/survey_browse_response.py index 6e423cb53c1..40c75755e1f 100644 --- a/addons/survey/report/survey_browse_response.py +++ b/addons/survey/report/survey_browse_response.py @@ -218,16 +218,16 @@ class survey_browse_response(report_rml): """ if survey.note: rml += """ - """ + to_xml(tools.ustr(survey.note)) + """ + """ + to_xml(tools.ustr(survey.note or '')) + """ """ for page in survey.page_ids: rml += """ - Page :- """ + to_xml(tools.ustr(page.title)) + """ + Page :- """ + to_xml(tools.ustr(page.title or '')) + """ """ if page.note: rml += """ - """ + to_xml(tools.ustr(page.note)) + """ + """ + to_xml(tools.ustr(page.note or '')) + """ """ for que in page.question_ids: rml += """ diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 744829b2d45..cd3584f5361 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -31,6 +31,7 @@ from tools import to_xml import tools from mx.DateTime import * import netsvc +import os class survey_type(osv.osv): _name = 'survey.type' @@ -902,7 +903,7 @@ class survey_question_wiz(osv.osv_memory): context.update({'response_id':response_id}) report = self.create_report(cr, uid, [int(survey_id)], 'report.survey.browse.response', survey_data.title,context) attachments = [] - file = open("/tmp/" + survey_data.title + ".pdf") + file = open(tools.config['addons_path'] + '/survey/report/' + survey_data.title + ".pdf") file_data = "" while 1: line = file.readline() @@ -910,6 +911,8 @@ class survey_question_wiz(osv.osv_memory): if not line: break attachments.append((survey_data.title + ".pdf",file_data)) + file.close() + os.remove(tools.config['addons_path'] + '/survey/report/' + survey_data.title + ".pdf") user_email = False resp_email = False if user_obj.browse(cr, uid, uid).address_id.id: @@ -938,7 +941,7 @@ class survey_question_wiz(osv.osv_memory): if not report_name or not res_ids: return (False, Exception('Report name and Resources ids are required !!!')) try: - ret_file_name = '/tmp/'+file_name+'.pdf' + ret_file_name = tools.config['addons_path'] + '/survey/report/' + file_name + '.pdf' service = netsvc.LocalService(report_name); (result, format) = service.create(cr, uid, res_ids, {}, context) fp = open(ret_file_name, 'wb+'); diff --git a/addons/survey/wizard/wizard_survey.py b/addons/survey/wizard/wizard_survey.py index b623c8ecd27..631b8d56aea 100755 --- a/addons/survey/wizard/wizard_survey.py +++ b/addons/survey/wizard/wizard_survey.py @@ -114,7 +114,7 @@ def send_mail(self, cr, uid, data, context): attachments = [] for id in survey_ref.browse(cr, uid, data['ids']): report = create_report(cr, uid, [id.id], 'report.survey.form', id.title) - file = open("/tmp/" + id.title +".pdf") + file = open(tools.config['addons_path'] + '/survey/report/' + id.title +".pdf") file_data = "" while 1: line = file.readline() @@ -122,6 +122,8 @@ def send_mail(self, cr, uid, data, context): if not line: break attachments.append((id.title +".pdf",file_data)) + file.close() + os.remove(tools.config['addons_path'] + '/survey/report/' + id.title + ".pdf") for partner in pool.get('res.partner').browse(cr, uid, partner_ids): for addr in partner.address: @@ -191,7 +193,7 @@ def create_report(cr, uid, res_ids, report_name=False, file_name=False): if not report_name or not res_ids: return (False, Exception('Report name and Resources ids are required !!!')) try: - ret_file_name = '/tmp/'+file_name+'.pdf' + ret_file_name = tools.config['addons_path'] + '/survey/report/' + file_name + '.pdf' service = netsvc.LocalService(report_name); (result, format) = service.create(cr, uid, res_ids, {}, {}) fp = open(ret_file_name, 'wb+');