[IMP] base: clean compatibility kw
Revision 6e36cbc243c41 changed the signature of the method in 11.0 for python 3.7 compatibility. To avoid breaking calls, introduced as fallback using kwargs. Remove this ugly hack for v12
This commit is contained in:
@@ -111,10 +111,7 @@ class AssetsBundle(object):
|
||||
self.javascripts.append(JavascriptAsset(self, url=f['url'], filename=f['filename'], inline=f['content']))
|
||||
|
||||
# depreciated and will remove after v11
|
||||
def to_html(self, sep=None, css=True, js=True, debug=False, async_load=False, url_for=(lambda url: url), **kw):
|
||||
if 'async' in kw:
|
||||
_logger.warning("Using deprecated argument 'async' in to_html call, use 'async_load' instead.")
|
||||
async_load = kw['async']
|
||||
def to_html(self, sep=None, css=True, js=True, debug=False, async_load=False, url_for=(lambda url: url)):
|
||||
nodes = self.to_node(css=css, js=js, debug=debug, async_load=async_load)
|
||||
|
||||
if sep is None:
|
||||
@@ -133,13 +130,10 @@ class AssetsBundle(object):
|
||||
|
||||
return sep + sep.join(response)
|
||||
|
||||
def to_node(self, css=True, js=True, debug=False, async_load=False, **kw):
|
||||
def to_node(self, css=True, js=True, debug=False, async_load=False):
|
||||
"""
|
||||
:returns [(tagName, attributes, content)] if the tag is auto close
|
||||
"""
|
||||
if 'async' in kw:
|
||||
_logger.warning("Using deprecated argument 'async' in to_node call, use 'async_load' instead.")
|
||||
async_load = kw['async']
|
||||
response = []
|
||||
if debug == 'assets':
|
||||
if css and self.stylesheets:
|
||||
|
||||
@@ -179,7 +179,7 @@ class IrQWeb(models.AbstractModel, QWeb):
|
||||
args=[ast.Str('debug')],
|
||||
keywords=[], starargs=None, kwargs=None
|
||||
)),
|
||||
ast.keyword('async', self._get_attr_bool(el.get('async', False))),
|
||||
ast.keyword('async_load', self._get_attr_bool(el.get('async_load', False))),
|
||||
ast.keyword('values', ast.Name(id='values', ctx=ast.Load())),
|
||||
],
|
||||
starargs=None, kwargs=None
|
||||
@@ -278,11 +278,9 @@ class IrQWeb(models.AbstractModel, QWeb):
|
||||
# compatibility to remove after v11 - DEPRECATED
|
||||
@tools.conditional(
|
||||
'xml' not in tools.config['dev_mode'],
|
||||
tools.ormcache_context('xmlid', 'options.get("lang", "en_US")', 'css', 'js', 'debug', 'kw.get("async")', 'async_load', keys=("website_id",)),
|
||||
tools.ormcache_context('xmlid', 'options.get("lang", "en_US")', 'css', 'js', 'debug', 'async_load', keys=("website_id",)),
|
||||
)
|
||||
def _get_asset(self, xmlid, options, css=True, js=True, debug=False, async_load=False, values=None, **kw):
|
||||
if 'async' in kw:
|
||||
async_load = kw['async']
|
||||
def _get_asset(self, xmlid, options, css=True, js=True, debug=False, async_load=False, values=None):
|
||||
files, remains = self._get_asset_content(xmlid, options)
|
||||
asset = self.get_asset_bundle(xmlid, files, remains, env=self.env)
|
||||
return asset.to_html(css=css, js=js, debug=debug, async_load=async_load, url_for=(values or {}).get('url_for', lambda url: url))
|
||||
@@ -291,11 +289,9 @@ class IrQWeb(models.AbstractModel, QWeb):
|
||||
# in non-xml-debug mode we want assets to be cached forever, and the admin can force a cache clear
|
||||
# by restarting the server after updating the source code (or using the "Clear server cache" in debug tools)
|
||||
'xml' not in tools.config['dev_mode'],
|
||||
tools.ormcache_context('xmlid', 'options.get("lang", "en_US")', 'css', 'js', 'debug', 'kw.get("async")', 'async_load', keys=("website_id",)),
|
||||
tools.ormcache_context('xmlid', 'options.get("lang", "en_US")', 'css', 'js', 'debug', 'async_load', keys=("website_id",)),
|
||||
)
|
||||
def _get_asset_nodes(self, xmlid, options, css=True, js=True, debug=False, async_load=False, values=None, **kw):
|
||||
if 'async' in kw:
|
||||
async_load = kw['async']
|
||||
def _get_asset_nodes(self, xmlid, options, css=True, js=True, debug=False, async_load=False, values=None):
|
||||
files, remains = self._get_asset_content(xmlid, options)
|
||||
asset = self.get_asset_bundle(xmlid, files, env=self.env)
|
||||
remains = [node for node in remains if (css and node[0] == 'link') or (js and node[0] != 'link')]
|
||||
|
||||
Reference in New Issue
Block a user