Skip destroyed records when fetching data from the server
issue9669 review294631002
This commit is contained in:
1 parent
0e4b8a6120
commit
0400d83cc8
1 file changed
+16
-2
+16
-2
@@ -269,6 +269,7 @@
|
||||
context._timestamp = {};
|
||||
records.forEach(function(record) {
|
||||
jQuery.extend(context._timestamp, record.get_timestamp());
|
||||
record.destroy();
|
||||
});
|
||||
var record_ids = records.map(function(record) {
|
||||
return record.id;
|
||||
@@ -560,6 +561,7 @@
|
||||
this.state_attrs = {};
|
||||
this.autocompletion = {};
|
||||
this.exception = false;
|
||||
this.destroyed = false;
|
||||
},
|
||||
has_changed: function() {
|
||||
return !jQuery.isEmptyObject(this._changed);
|
||||
@@ -629,7 +631,7 @@
|
||||
if (async === undefined) {
|
||||
async = true;
|
||||
}
|
||||
if (this.is_loaded(name)) {
|
||||
if (this.destroyed || this.is_loaded(name)) {
|
||||
return async? jQuery.when() : this.model.fields[name];
|
||||
}
|
||||
if (this.group.prm.state() == 'pending') {
|
||||
@@ -700,7 +702,9 @@
|
||||
10);
|
||||
|
||||
var filter_group = function(record) {
|
||||
return !(name in record._loaded) && (record.id >= 0);
|
||||
return (!record.destroyed &&
|
||||
(record.id >= 0) &&
|
||||
!(name in record._loaded));
|
||||
};
|
||||
var filter_parent_group = function(record) {
|
||||
return (filter_group(record) &&
|
||||
@@ -1431,6 +1435,16 @@
|
||||
this.button_clicks[name] = clicks;
|
||||
return clicks;
|
||||
}.bind(this));
|
||||
},
|
||||
destroy: function() {
|
||||
var vals = Object.values(this._values);
|
||||
for (var i=0; i < vals.length; i++) {
|
||||
var val = vals[i];
|
||||
if (val.hasOwnProperty('destroy')) {
|
||||
val.destroy();
|
||||
}
|
||||
}
|
||||
this.destroyed = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user