[IMP] netsvc: LocalService deprecation now guarded via openerp.conf.deprecation.

bzr revid: vmt@openerp.com-20130325131245-9o5uizn6v4r8irc3
This commit is contained in:
Vo Minh Thu 2013-03-25 14:12:45 +01:00
parent 6e43e6c4e1
commit 464af881bf
3 changed files with 25 additions and 1 deletions

View File

@ -26,6 +26,8 @@ additional code is needed throughout the core library. This module keeps
track of those specific measures by providing variables that can be unset
by the user to check if her code is future proof.
In a perfect world, all these variables are set to False, the corresponding
code removed, and thus these variables made unnecessary.
"""
# If True, the Python modules inside the openerp namespace are made available
@ -35,4 +37,14 @@ by the user to check if her code is future proof.
# Change to False around 2013.02.
open_openerp_namespace = False
# If True, openerp.netsvc.LocalService() can be used to lookup reports or to
# access openerp.workflow.
# Introduced around 2013.03.
# Among the related code:
# - The openerp.netsvc.LocalService() function.
# - The openerp.report.interface.report_int._reports dictionary.
# - The register attribute in openerp.report.report_sxw (and in its inheriting
# classes).
allow_local_service = True
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -52,7 +52,8 @@ def LocalService(name):
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)
assert openerp.conf.deprecation.allow_local_service
_logger.warning("LocalService() is deprecated since march 2013 (it was called with '%s')." % name)
if name == 'workflow':
return openerp.workflow

View File

@ -388,6 +388,17 @@ class rml_parse(object):
self.setCompany(objects[0].company_id)
class report_sxw(report_rml, preprocess.report):
"""
The register=True kwarg has been added to help remove the
openerp.netsvc.LocalService() indirection and the related
openerp.report.interface.report_int._reports dictionary:
report_sxw registered in XML with auto=False are also registered in Python.
In that case, they are registered in the above dictionary. Since
registration is automatically done upon instanciation, and that
instanciation is needed before rendering, a way was needed to
instanciate-without-register a report. In the future, no report
should be registered in the above dictionary and it will be dropped.
"""
def __init__(self, name, table, rml=False, parser=rml_parse, header='external', store=False, register=True):
report_rml.__init__(self, name, table, rml, '', register=register)
self.name = name