summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/data.js
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2013-04-16 17:20:00 +0200
committerXavier Morel <xmo@openerp.com>2013-04-16 17:20:00 +0200
commitc19bc506484d162d7d85beab6d2c0efbbf474035 (patch)
tree5293e6e919e2f316cea6c281e64f5179be6ef84d /addons/web/static/src/js/data.js
parenta455d6c2b27fb8a90c8993abb176da64c0952b5c (diff)
[FIX] ids of deleted records living in shared dataset when clicking on list row
When a record is activated, the listview will do some jiggling around assigning the ids of internal dataset to the one shared between all views, this is mostly for the case where one switches from a "grouped" list view, so the form view only cycles on the "current" group. Problem is, that internal dataset is not correctly synchronized with the shared one, so when the id is removed from the shared dataset it is *not* removed from the internal one(s), and when the switch is made the ids from the internal dataset are set on the shared one and reintroduce the deleted record, leading to the form view's incorrect state. Fix the issue by updating the dataset's ids list when a record is deleted from the records tree. Also extracted some stuff from DataSetSearch's unlink callback so it can be overridden and is more stable across datasets. lp bug: https://launchpad.net/bugs/1161210 fixed bzr revid: xmo@openerp.com-20130416152000-06dbwkgdb8zlf9pc
Diffstat (limited to 'addons/web/static/src/js/data.js')
-rw-r--r--addons/web/static/src/js/data.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js
index a36441add1c..d60f72c6577 100644
--- a/addons/web/static/src/js/data.js
+++ b/addons/web/static/src/js/data.js
@@ -607,6 +607,9 @@ instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin,
alter_ids: function(n_ids) {
this.ids = n_ids;
},
+ remove_ids: function (ids) {
+ this.alter_ids(_(this.ids).difference(ids));
+ },
/**
* Resequence records.
*
@@ -704,17 +707,23 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({
get_domain: function (other_domain) {
this._model.domain(other_domain);
},
+ alter_ids: function (ids) {
+ this._super(ids);
+ if (this.index !== null && this.index >= this.ids.length) {
+ this.index = this.ids.length > 0 ? this.ids.length - 1 : 0;
+ }
+ },
+ remove_ids: function (ids) {
+ var before = this.ids.length;
+ this._super(ids);
+ if (this._length) {
+ this._length -= (before - this.ids.length);
+ }
+ },
unlink: function(ids, callback, error_callback) {
var self = this;
return this._super(ids).done(function(result) {
- self.ids = _(self.ids).difference(ids);
- if (self._length) {
- self._length -= 1;
- }
- if (self.index !== null) {
- self.index = self.index <= self.ids.length - 1 ?
- self.index : (self.ids.length > 0 ? self.ids.length -1 : 0);
- }
+ self.remove_ids( ids);
self.trigger("dataset_changed", ids, callback, error_callback);
});
},