[MERGE] trunk-trigger-dataset_on_change.
bzr revid: vta@openerp.com-20121015075414-uzcv7oirczkk0fjw
This commit is contained in:
commit
fca9f19f76
|
@ -568,7 +568,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
|
||||||
*/
|
*/
|
||||||
write: function (id, data, options) {
|
write: function (id, data, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
return this._model.call('write', [[id], data], {context: this._model.context(options.context)});
|
return this._model.call('write', [[id], data], {context: this._model.context(options.context)}).then(this.trigger('dataset_changed', id, data, options));
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Deletes an existing record from the database
|
* Deletes an existing record from the database
|
||||||
|
@ -576,8 +576,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
|
||||||
* @param {Number|String} ids identifier of the record to delete
|
* @param {Number|String} ids identifier of the record to delete
|
||||||
*/
|
*/
|
||||||
unlink: function(ids) {
|
unlink: function(ids) {
|
||||||
this.trigger('unlink', ids);
|
return this._model.call('unlink', [ids], {context: this._model.context()}).then(this.trigger('dataset_changed', ids));
|
||||||
return this._model.call('unlink', [ids], {context: this._model.context()});
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Calls an arbitrary RPC method
|
* Calls an arbitrary RPC method
|
||||||
|
@ -779,6 +778,7 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({
|
||||||
self.index = self.index <= self.ids.length - 1 ?
|
self.index = self.index <= self.ids.length - 1 ?
|
||||||
self.index : (self.ids.length > 0 ? self.ids.length -1 : 0);
|
self.index : (self.ids.length > 0 ? self.ids.length -1 : 0);
|
||||||
}
|
}
|
||||||
|
this.trigger("dataset_changed", ids, callback, error_callback);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
size: function () {
|
size: function () {
|
||||||
|
@ -835,7 +835,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
|
||||||
}
|
}
|
||||||
$.extend(cached.values, record.values);
|
$.extend(cached.values, record.values);
|
||||||
if (dirty)
|
if (dirty)
|
||||||
this.on_change();
|
this.trigger("dataset_changed", id, data, options);
|
||||||
return $.Deferred().resolve(true).promise();
|
return $.Deferred().resolve(true).promise();
|
||||||
},
|
},
|
||||||
unlink: function(ids, callback, error_callback) {
|
unlink: function(ids, callback, error_callback) {
|
||||||
|
@ -849,7 +849,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
|
||||||
this.to_write = _.reject(this.to_write, function(x) { return _.include(ids, x.id);});
|
this.to_write = _.reject(this.to_write, function(x) { return _.include(ids, x.id);});
|
||||||
this.cache = _.reject(this.cache, function(x) { return _.include(ids, x.id);});
|
this.cache = _.reject(this.cache, function(x) { return _.include(ids, x.id);});
|
||||||
this.set_ids(_.without.apply(_, [this.ids].concat(ids)));
|
this.set_ids(_.without.apply(_, [this.ids].concat(ids)));
|
||||||
this.on_change();
|
this.trigger("dataset_changed", ids, callback, error_callback);
|
||||||
return $.async_when({result: true}).then(callback);
|
return $.async_when({result: true}).then(callback);
|
||||||
},
|
},
|
||||||
reset_ids: function(ids) {
|
reset_ids: function(ids) {
|
||||||
|
@ -860,8 +860,6 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
|
||||||
this.cache = [];
|
this.cache = [];
|
||||||
this.delete_all = false;
|
this.delete_all = false;
|
||||||
},
|
},
|
||||||
on_change: function() {
|
|
||||||
},
|
|
||||||
read_ids: function (ids, fields, options) {
|
read_ids: function (ids, fields, options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var to_get = [];
|
var to_get = [];
|
||||||
|
@ -948,7 +946,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
|
||||||
},
|
},
|
||||||
alter_ids: function(n_ids) {
|
alter_ids: function(n_ids) {
|
||||||
this._super(n_ids);
|
this._super(n_ids);
|
||||||
this.on_change();
|
this.trigger("dataset_changed", n_ids);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
instance.web.BufferedDataSet.virtual_id_regex = /^one2many_v_id_.*$/;
|
instance.web.BufferedDataSet.virtual_id_regex = /^one2many_v_id_.*$/;
|
||||||
|
|
|
@ -749,7 +749,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
on_button_save: function() {
|
on_button_save: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
return this.save().then(function(result) {
|
return this.save().then(function(result) {
|
||||||
self.trigger("save");
|
self.trigger("save", result);
|
||||||
self.to_view_mode();
|
self.to_view_mode();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -3288,7 +3288,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
|
||||||
this.dataset.o2m = this;
|
this.dataset.o2m = this;
|
||||||
this.dataset.parent_view = this.view;
|
this.dataset.parent_view = this.view;
|
||||||
this.dataset.child_name = this.name;
|
this.dataset.child_name = this.name;
|
||||||
this.dataset.on_change.add_last(function() {
|
this.dataset.on('dataset_changed', this, function() {
|
||||||
self.trigger_on_change();
|
self.trigger_on_change();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3583,7 +3583,7 @@ instance.web.form.One2ManyViewManager = instance.web.ViewManager.extend({
|
||||||
create_function: function(data) {
|
create_function: function(data) {
|
||||||
return self.o2m.dataset.create(data).then(function(r) {
|
return self.o2m.dataset.create(data).then(function(r) {
|
||||||
self.o2m.dataset.set_ids(self.o2m.dataset.ids.concat([r]));
|
self.o2m.dataset.set_ids(self.o2m.dataset.ids.concat([r]));
|
||||||
self.o2m.dataset.on_change();
|
self.o2m.dataset.trigger("dataset_changed", r);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
write_function: function(id, data, options) {
|
write_function: function(id, data, options) {
|
||||||
|
@ -3673,7 +3673,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
|
||||||
create_function: function(data, callback, error_callback) {
|
create_function: function(data, callback, error_callback) {
|
||||||
return self.o2m.dataset.create(data).then(function(r) {
|
return self.o2m.dataset.create(data).then(function(r) {
|
||||||
self.o2m.dataset.set_ids(self.o2m.dataset.ids.concat([r]));
|
self.o2m.dataset.set_ids(self.o2m.dataset.ids.concat([r]));
|
||||||
self.o2m.dataset.on_change();
|
self.o2m.dataset.trigger("dataset_changed", r);
|
||||||
}).then(callback, error_callback);
|
}).then(callback, error_callback);
|
||||||
},
|
},
|
||||||
read_function: function() {
|
read_function: function() {
|
||||||
|
|
Loading…
Reference in New Issue