[FIX] base: lazy load external files if part of a lazy loaded bundle
In the payment_adyen module, files of adyen are added as part of the assets_frontend bundle. That bundle is lazy loaded on the website... but those external files were not, as not added within the bundle itself. This commit fixes that, properly lazy loading "remaining" files out of a lazy loaded assets bundle. closes odoo/odoo#77877 X-original-commit: 8dd71bdc42c8d4ab3373a2a0601c93d1687aabca Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
@@ -258,7 +258,7 @@ class IrQWeb(models.AbstractModel, QWeb):
|
||||
nodeAttrs = {
|
||||
'media': media,
|
||||
}
|
||||
files, remains = self._get_asset_content(bundle, nodeAttrs)
|
||||
files, remains = self._get_asset_content(bundle, nodeAttrs, defer_load=defer_load, lazy_load=lazy_load)
|
||||
asset = self.get_asset_bundle(bundle, files, env=self.env, css=css, js=js)
|
||||
remains = [node for node in remains if (css and node[0] == 'link') or (js and node[0] == 'script')]
|
||||
return remains + asset.to_node(css=css, js=js, debug=debug, async_load=async_load, defer_load=defer_load, lazy_load=lazy_load)
|
||||
@@ -268,7 +268,7 @@ class IrQWeb(models.AbstractModel, QWeb):
|
||||
return [node[1]['href'] for node in asset_nodes if node[0] == 'link']
|
||||
|
||||
@tools.ormcache_context('bundle', 'nodeAttrs and nodeAttrs.get("media")', keys=("website_id", "lang"))
|
||||
def _get_asset_content(self, bundle, nodeAttrs=None):
|
||||
def _get_asset_content(self, bundle, nodeAttrs=None, defer_load=False, lazy_load=False):
|
||||
asset_paths = self.env['ir.asset']._get_asset_paths(bundle=bundle, css=True, js=True)
|
||||
|
||||
files = []
|
||||
@@ -295,8 +295,10 @@ class IrQWeb(models.AbstractModel, QWeb):
|
||||
tag = 'script'
|
||||
attributes = {
|
||||
"type": mimetype,
|
||||
"src": path,
|
||||
}
|
||||
attributes["data-src" if lazy_load else "src"] = path
|
||||
if defer_load or lazy_load:
|
||||
attributes["defer"] = "defer"
|
||||
else:
|
||||
tag = 'link'
|
||||
attributes = {
|
||||
|
||||
Reference in New Issue
Block a user