[IMP]:survey:(REF-YSA)
-improved code. bzr revid: apa@tinyerp.com-20100210052542-v4r6mq8c9on0c7or
This commit is contained in:
parent
277924363e
commit
4db5d00fc1
|
@ -218,16 +218,16 @@ class survey_browse_response(report_rml):
|
|||
</blockTable>"""
|
||||
if survey.note:
|
||||
rml += """<blockTable colWidths='""" + _tbl_widths + """' style="note_table">
|
||||
<tr><td><para style="descriptive_text">""" + to_xml(tools.ustr(survey.note)) + """</para><para style="P2"><font></font></para></td></tr>
|
||||
<tr><td><para style="response">""" + to_xml(tools.ustr(survey.note or '')) + """</para><para style="P2"><font></font></para></td></tr>
|
||||
</blockTable>"""
|
||||
for page in survey.page_ids:
|
||||
rml += """<blockTable colWidths='""" + str(_tbl_widths) + """' style="page_tbl">
|
||||
<tr><td><para style="page">Page :- """ + to_xml(tools.ustr(page.title)) + """</para></td></tr>
|
||||
<tr><td><para style="page">Page :- """ + to_xml(tools.ustr(page.title or '')) + """</para></td></tr>
|
||||
</blockTable>"""
|
||||
if page.note:
|
||||
rml += """<para style="P2"></para>
|
||||
<blockTable colWidths='""" + str(_tbl_widths) + """' style="note_table">
|
||||
<tr><td><para style="response">""" + to_xml(tools.ustr(page.note)) + """</para></td></tr>
|
||||
<tr><td><para style="response">""" + to_xml(tools.ustr(page.note or '')) + """</para></td></tr>
|
||||
</blockTable>"""
|
||||
for que in page.question_ids:
|
||||
rml += """<para style="P2"></para>
|
||||
|
|
|
@ -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+');
|
||||
|
|
|
@ -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+');
|
||||
|
|
Loading…
Reference in New Issue