From 24c6e98685a67a507f69a6f8ceebbb29302efa9c Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 4 Aug 2017 18:02:17 +0200 Subject: [PATCH] [FIX] web: returns right deferred when loading same xml twice in a row Since commit 417a664f16abc67bee40a0067103f9cf2c412aed: The `ajax.loadXML` function has been refactored and improved so that multiple calls to the function with the same URL only loads it once and so that the deferred which is returned really indicates the status of loading this particular URL. Unfortunately, there was a mistake: when loading the same URL twice, the second call always returned an already resolved deferred if the first call to `ajax.loadXML` was done with this URL. --- addons/web/static/src/js/core/ajax.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/core/ajax.js b/addons/web/static/src/js/core/ajax.js index 2b4b480ac50..b56823c4e6f 100644 --- a/addons/web/static/src/js/core/ajax.js +++ b/addons/web/static/src/js/core/ajax.js @@ -415,8 +415,11 @@ var loadXML = (function () { if (loadingsData.length) { // There is something to load, load it, resolve the associated // deferred then start loading the next one - var loadingData = loadingsData.shift(); + var loadingData = loadingsData[0]; loadingData.qweb.add_template(loadingData.url, function () { + // Remove from array only now so that multiple calls to + // loadXML with the same URL returns the right deferred + loadingsData.shift(); loadingData.def.resolve(); _load(); });