diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 74b2ec87f01..cbfc4d061f5 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -783,11 +783,19 @@ openerp.web.BufferedDataSet = openerp.web.DataSetStatic.extend({ return completion.promise(); }, evict_from_cache: function (id) { + // Don't evict records which haven't yet been saved: there is no more + // recent data on the server (and there potentially isn't any data), + // and this breaks the assumptions of other methods (that the data + // for new and altered records is both in the cache and in the to_write + // or to_create collection) + if (_(this.to_create.concat(this.to_write)).find(function (record) { + return record.id === id; })) { + return; + } + for (var i = 0, len = this.cache.length; i < len; ++i) { var record = this.cache[i]; - // if record we call the button upon is in the cache if (record.id === id) { - // evict it so it gets reloaded from server this.cache.splice(i, 1); break; }