[FIX] reports: now that _register_all() has been removed, LocalService() must be modified to do the lookup in the database too.

bzr revid: vmt@openerp.com-20130325123359-szxx6a0n06tha70p
This commit is contained in:
Vo Minh Thu 2013-03-25 13:33:59 +01:00
parent 010d8044fe
commit 6e43e6c4e1
2 changed files with 26 additions and 3 deletions

View File

@ -85,9 +85,9 @@ class report_xml(osv.osv):
res[report.id] = False
return res
def render_report(self, cr, uid, res_ids, name, data, context=None):
def _lookup_report(self, cr, name):
"""
Look up a report definition and render the report for the provided IDs.
Look up a report definition.
"""
import openerp
import operator
@ -119,6 +119,13 @@ class report_xml(osv.osv):
else:
raise Exception, "Required report does not exist: %s" % r
return new_report
def render_report(self, cr, uid, res_ids, name, data, context=None):
"""
Look up a report definition and render the report for the provided IDs.
"""
new_report = self._lookup_report(cr, name)
return new_report.create(cr, uid, res_ids, data, context)
_name = 'ir.actions.report.xml'

View File

@ -44,13 +44,29 @@ import openerp
_logger = logging.getLogger(__name__)
def LocalService(name):
"""
The openerp.netsvc.LocalService() fucntion is deprecated. It still works
in two cases: workflows and reports. For workflows, instead of using
LocalService('workflow'), openerp.workflow should be used (better yet,
methods on openerp.osv.orm.Model should be used). For reports,
openerp.report.render_report() should be used (methods on the Model should
be provided too in the future).
"""
_logger.warning("LocalService('%s') is deprecated." % name)
if name == 'workflow':
return openerp.workflow
if name.startswith('report.'):
return openerp.report.interface.report_int._reports[name]
report = openerp.report.interface.report_int._reports.get(name)
if report:
return report
else:
dbname = getattr(threading.currentThread(), 'dbname', None)
if dbname:
registry = openerp.modules.registry.RegistryManager.get(dbname)
with registry.cursor() as cr:
return registry['ir.actions.report.xml']._lookup_report(cr, name[len('report.'):])
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, _NOTHING, DEFAULT = range(10)
#The background is set with 40 plus the number of the color, and the foreground with 30