From cf85f3b082c49a21cfde0d04299a80724a40f420 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 3 Apr 2020 13:33:44 +0000 Subject: [PATCH] [FIX] web: fix ajax.loadAsset cache The caching system which was implemented was not working if the same asset was asked twice "at the same time" = "if the second demand occured while the first demand's RPC loading was taking place". Part of https://github.com/odoo/odoo/pull/48981 X-original-commit: ba0ac348a3700331cec6955625ca2b6c72600ced --- addons/web/static/src/js/core/ajax.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/core/ajax.js b/addons/web/static/src/js/core/ajax.js index 67a46e29d55..c48ae4c0254 100644 --- a/addons/web/static/src/js/core/ajax.js +++ b/addons/web/static/src/js/core/ajax.js @@ -441,7 +441,7 @@ var loadAsset = (function () { var load = function loadAsset(xmlId, context) { if (cache[xmlId]) { - return Promise.resolve(cache[xmlId]); + return cache[xmlId]; } context = _.extend({}, odoo.session_info.user_context, context); var params = { @@ -454,9 +454,9 @@ var loadAsset = (function () { method: 'render_template', model: 'ir.ui.view', }; - return rpc('/web/dataset/call_kw/ir.ui.view/render_template', params).then(function (xml) { + cache[xmlId] = rpc('/web/dataset/call_kw/ir.ui.view/render_template', params).then(function (xml) { var $xml = $(xml); - cache[xmlId] = { + return { cssLibs: $xml.filter('link[href]:not([type="image/x-icon"])').map(function () { return $(this).attr('href'); }).get(), @@ -470,8 +470,8 @@ var loadAsset = (function () { return $(this).html(); }).get(), }; - return cache[xmlId]; }); + return cache[xmlId]; }; return load;