Skip to content

Commit

Permalink
[FIX] base: keep _get_asset for retro compatibility
Browse files Browse the repository at this point in the history
Return of _get_assets has been altered with commit 9cd982b
We keep it for retro compatibility, but devs that override it before need to
override now _get_asset_node to be called correctly by t-call-asset.
  • Loading branch information
JKE-be committed Jun 22, 2018
1 parent 55e2d24 commit df4072b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions odoo/addons/base/ir/ir_qweb/ir_qweb.py
Expand Up @@ -174,7 +174,7 @@ def _compile_directive_call_assets(self, el, options):
value=ast.Call(
func=ast.Attribute(
value=ast.Name(id='self', ctx=ast.Load()),
attr='_get_asset',
attr='_get_asset_nodes',
ctx=ast.Load()
),
args=[
Expand Down Expand Up @@ -286,13 +286,23 @@ def _compile_widget_options(self, el, directive_type):

# method called by computing code

# 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', 'async', keys=("website_id",)),
)
def _get_asset(self, xmlid, options, css=True, js=True, debug=False, async=False, values=None):
files, remains = self._get_asset_content(xmlid, options)
asset = AssetsBundle(xmlid, files, remains, env=self.env)
return asset.to_html(css=css, js=js, debug=debug, async=async, url_for=(values or {}).get('url_for', lambda url: url))

@tools.conditional(
# 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', 'async', keys=("website_id",)),
)
def _get_asset(self, xmlid, options, css=True, js=True, debug=False, async=False, values=None):
def _get_asset_nodes(self, xmlid, options, css=True, js=True, debug=False, async=False, values=None):
files, remains = self._get_asset_content(xmlid, options)
asset = AssetsBundle(xmlid, files, env=self.env)
remains = [node for node in remains if (css and node[0] == 'link') or (js and node[0] != 'link')]
Expand Down

0 comments on commit df4072b

Please sign in to comment.