[IMP] report: use openerp.report.render_report() instead of LocalService().create().
bzr revid: vmt@openerp.com-20130222124823-6u7cqzj3d60buud5
This commit is contained in:
parent
eb5fa511ec
commit
76ec85fca1
|
@ -29,7 +29,6 @@ import urllib2
|
|||
|
||||
import openerp
|
||||
import openerp.release as release
|
||||
import openerp.netsvc as netsvc
|
||||
from openerp.osv import osv, fields
|
||||
from openerp.tools.translate import _
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
|
@ -418,9 +417,7 @@ class EDIMixin(object):
|
|||
('usage','=','default')])
|
||||
if matching_reports:
|
||||
report = ir_actions_report.browse(cr, uid, matching_reports[0])
|
||||
report_service = 'report.' + report.report_name
|
||||
service = netsvc.LocalService(report_service)
|
||||
(result, format) = service.create(cr, uid, [record.id], {'model': self._name}, context=context)
|
||||
result, format = openerp.report.render_report(cr, uid, [record.id], report.report_name, {'model': self._name}, context=context)
|
||||
eval_context = {'time': time, 'object': record}
|
||||
if not report.attachment or not eval(report.attachment, eval_context):
|
||||
# no auto-saving of report as attachment, need to do it manually
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
import base64
|
||||
import logging
|
||||
|
||||
from openerp import netsvc
|
||||
import openerp
|
||||
from openerp.osv import osv, fields
|
||||
from openerp.osv import fields
|
||||
from openerp import tools
|
||||
|
@ -331,16 +331,15 @@ class email_template(osv.osv):
|
|||
# Add report in attachments
|
||||
if template.report_template:
|
||||
report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=context)
|
||||
report_service = 'report.' + report_xml_pool.browse(cr, uid, template.report_template.id, context).report_name
|
||||
report_service = report_xml_pool.browse(cr, uid, template.report_template.id, context).report_name
|
||||
# Ensure report is rendered using template's language
|
||||
ctx = context.copy()
|
||||
if template.lang:
|
||||
ctx['lang'] = self.render_template(cr, uid, template.lang, template.model, res_id, context)
|
||||
service = netsvc.LocalService(report_service)
|
||||
(result, format) = service.create(cr, uid, [res_id], {'model': template.model}, ctx)
|
||||
result, format = openerp.report.render_report(cr, uid, [res_id], report_service, {'model': template.model}, ctx)
|
||||
result = base64.b64encode(result)
|
||||
if not report_name:
|
||||
report_name = report_service
|
||||
report_name = 'report.' + report_service
|
||||
ext = "." + format
|
||||
if not report_name.endswith(ext):
|
||||
report_name += ext
|
||||
|
|
|
@ -32,7 +32,6 @@ import re
|
|||
from openerp.addons.decimal_precision import decimal_precision as dp
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
from openerp import netsvc
|
||||
from openerp.tools.translate import _
|
||||
|
||||
_intervalTypes = {
|
||||
|
|
|
@ -25,8 +25,9 @@ from lxml import etree
|
|||
import os
|
||||
from time import strftime
|
||||
|
||||
from openerp import addons, netsvc, tools
|
||||
from openerp import addons, tools
|
||||
from openerp.osv import fields, osv
|
||||
import openerp.report
|
||||
from openerp.tools import to_xml
|
||||
from openerp.tools.translate import _
|
||||
from openerp.tools.safe_eval import safe_eval
|
||||
|
@ -463,8 +464,7 @@ class survey_question_wiz(osv.osv_memory):
|
|||
return (False, Exception('Report name and Resources ids are required !!!'))
|
||||
try:
|
||||
uid = 1
|
||||
service = netsvc.LocalService(report_name);
|
||||
(result, format) = service.create(cr, uid, res_ids, {}, context)
|
||||
result, format = openerp.report.render_report(cr, uid, res_ids, report_name[len('report.'):], {}, context)
|
||||
ret_file_name = addons.get_module_resource('survey', 'report') + file_name + '.pdf'
|
||||
fp = open(ret_file_name, 'wb+');
|
||||
fp.write(result);
|
||||
|
|
|
@ -26,8 +26,9 @@ import os
|
|||
import datetime
|
||||
import socket
|
||||
|
||||
from openerp import addons, netsvc, tools
|
||||
from openerp import addons, tools
|
||||
from openerp.osv import fields, osv
|
||||
import openerp.report
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
|
@ -85,8 +86,7 @@ Thanks,''') % (name, self.pool.get('ir.config_parameter').get_param(cr, uid, 'we
|
|||
return (False, Exception('Report name and Resources ids are required !!!'))
|
||||
try:
|
||||
ret_file_name = addons.get_module_resource('survey', 'report') + file_name + '.pdf'
|
||||
service = netsvc.LocalService(report_name);
|
||||
(result, format) = service.create(cr, uid, res_ids, {}, {})
|
||||
result, format = openerp.report.render_report(cr, uid, res_ids, report_name[len('report.'):], {}, {})
|
||||
fp = open(ret_file_name, 'wb+');
|
||||
fp.write(result);
|
||||
fp.close();
|
||||
|
|
Loading…
Reference in New Issue