summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework/data_manager.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2016-05-17 13:09:15 +0200
committerAaron Bohy <aab@odoo.com>2016-05-18 09:39:17 +0200
commite80c2bd17e2ba7e8ed1fbd40696045283efe301d (patch)
tree1e35d87fcf5ae7225d5028a79bae1011b15b9bb9 /addons/web/static/src/js/framework/data_manager.js
parente38ddcfeae647da3da19fee0491606bc70df0dd3 (diff)
[FIX] web: data_manager: invalidate cache on RPC fail
Before this rev., if an error occured during an RPC handled by the data_manager, the RPC result was stored in cache anyway, and there was thus no other way than refreshing the page to get correct result for that RPC.
Diffstat (limited to 'addons/web/static/src/js/framework/data_manager.js')
-rw-r--r--addons/web/static/src/js/framework/data_manager.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/addons/web/static/src/js/framework/data_manager.js b/addons/web/static/src/js/framework/data_manager.js
index 8065b48b4e1..73521e1a06d 100644
--- a/addons/web/static/src/js/framework/data_manager.js
+++ b/addons/web/static/src/js/framework/data_manager.js
@@ -36,7 +36,7 @@ return core.Class.extend({
}).then(function (action) {
self._cache.actions[key] = action.no_cache ? null : self._cache.actions[key];
return action;
- });
+ }, this._invalidate.bind(this, this._cache.actions, key));
}
return this._cache.actions[key];
@@ -94,7 +94,7 @@ return core.Class.extend({
}
return result.fields_views;
- });
+ }, this._invalidate.bind(this, this._cache.views, key));
}
return this._cache.views[key];
@@ -117,7 +117,7 @@ return core.Class.extend({
view_type: view_type,
toolbar: toolbar,
context: dataset.get_context(),
- }).then(this._postprocess_fvg.bind(this));
+ }).then(this._postprocess_fvg.bind(this), this._invalidate.bind(this, this._cache.fields_views, key));
}
return this._cache.fields_views[key];
},
@@ -132,7 +132,7 @@ return core.Class.extend({
if (!this._cache.fields[dataset.model]) {
this._cache.fields[dataset.model] = dataset.call('fields_get', {
context: dataset.get_context(),
- });
+ }).fail(this._invalidate.bind(this, this._cache.fields, dataset.model));
}
return this._cache.fields[dataset.model];
},
@@ -149,7 +149,7 @@ return core.Class.extend({
if (!this._cache.filters[key]) {
this._cache.filters[key] = this.Filters.call('get_filters', [dataset.model, action_id], {
context: dataset.get_context(),
- });
+ }).fail(this._invalidate.bind(this, this._cache.filters, key));
}
return this._cache.filters[key];
},
@@ -169,7 +169,7 @@ return core.Class.extend({
filter.model_id,
filter.action_id || false,
].join(',');
- self._cache.filters[key] = null; // invalidate cache
+ self._invalidate(self._cache.filters, key);
return filter_id;
});
},
@@ -221,6 +221,13 @@ return core.Class.extend({
return _.isObject(arg) ? JSON.stringify(arg) : arg;
}).join(',');
},
+
+ /**
+ * Private function that invalidates a cache entry
+ */
+ _invalidate: function (cache, key) {
+ delete cache[key];
+ },
});
});