[FIX] o2m breakage introduced in xmo@openerp.com-20120903131744-xfnxpqgn4ixbi7e9
BufferedDataSet#read_ids expect coherent between #cache and #to_create, patch removed a record from #cache which was in #to_create leading to not being able to create new records in editable o2ms: * The record would be inserted in #cache and #to_create * The listview would reload the record - Evicting the record from #cache - And re-reading the record - Leading to breakage Don't evict records locally edited from the cache, the server probably doesn't know about it (at all) or we can assume the server's outdated, so the local version remains the "correct" one and there's nothing more recent to fetch. bzr revid: xmo@openerp.com-20120906124816-8ivtbppm9pixf8w6
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user