[FIX] triggering of dataset_changed events to correctly happen *after* the operation
authorXavier Morel <xmo@openerp.com>
Thu, 30 May 2013 13:11:15 +0000 (15:11 +0200)
committerXavier Morel <xmo@openerp.com>
Thu, 30 May 2013 13:11:15 +0000 (15:11 +0200)
also added it to DataSet#create calls where it seems to be missing

lp bug: https://launchpad.net/bugs/1185752 fixed

bzr revid: xmo@openerp.com-20130530131115-tzap50w2ydnqmxit

addons/web/static/src/js/data.js

index d60f72c..f7dd6d2 100644 (file)
@@ -490,7 +490,12 @@ instance.web.DataSet =  instance.web.Class.extend(instance.web.PropertiesMixin,
      * @returns {$.Deferred}
      */
     create: function(data, options) {
-        return this._model.call('create', [data], {context: this.get_context()});
+        var self = this;
+        return this._model.call('create', [data], {
+            context: this.get_context()
+        }).done(function () {
+            self.trigger('dataset_changed', data, options)
+        });
     },
     /**
      * Saves the provided data in an existing db record
@@ -505,7 +510,12 @@ instance.web.DataSet =  instance.web.Class.extend(instance.web.PropertiesMixin,
      */
     write: function (id, data, options) {
         options = options || {};
-        return this._model.call('write', [[id], data], {context: this.get_context(options.context)}).done(this.trigger('dataset_changed', id, data, options));
+        var self = this;
+        return this._model.call('write', [[id], data], {
+            context: this.get_context(options.context)
+        }).done(function () {
+            self.trigger('dataset_changed', id, data, options)
+        });
     },
     /**
      * Deletes an existing record from the database
@@ -513,7 +523,12 @@ instance.web.DataSet =  instance.web.Class.extend(instance.web.PropertiesMixin,
      * @param {Number|String} ids identifier of the record to delete
      */
     unlink: function(ids) {
-        return this._model.call('unlink', [ids], {context: this.get_context()}).done(this.trigger('dataset_changed', ids));
+        var self = this;
+        return this._model.call('unlink', [ids], {
+            context: this.get_context()
+        }).done(function () {
+            self.trigger('dataset_changed', ids)
+        });
     },
     /**
      * Calls an arbitrary RPC method