[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
This commit is contained in:
qsm-odoo
2020-04-10 11:54:02 +00:00
parent a7b9448033
commit cf85f3b082
+4 -4
View File
@@ -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;