Vidhin Mehta  (OpenERP) has proposed merging 
lp:~openerp-dev/openerp-web/trunk-deferred-write into lp:openerp-web.

Requested reviews:
  OpenERP R&D Web Team (openerp-dev-web)

For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-deferred-write/+merge/127211

Remove callbacks from write method,update related code and tested with browser 
debugger.
-- 
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-deferred-write/+merge/127211
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openerp-web/trunk-deferred-write.
=== modified file 'addons/web/static/src/js/data.js'
--- addons/web/static/src/js/data.js	2012-09-30 15:18:06 +0000
+++ addons/web/static/src/js/data.js	2012-10-01 09:21:50 +0000
@@ -648,12 +648,11 @@
      * @param {Function} error_callback function called in case of write error
      * @returns {$.Deferred}
      */
-    write: function (id, data, options, callback, error_callback) {
+    write: function (id, data, options) {
         options = options || {};
         return this._model.call('write',
             [[id], data], {context: this._model.context(options.context)})
-                .pipe(function (r) { return {result: r}})
-                    .then(callback, error_callback);
+                .pipe(function (r) { return {result: r}});
     },
     /**
      * Deletes an existing record from the database
@@ -918,7 +917,7 @@
         this.cache.push(cached);
         return $.Deferred().resolve({result: cached.id}).promise();
     },
-    write: function (id, data, options, callback) {
+    write: function (id, data, options) {
         var self = this;
         var record = _.detect(this.to_create, function(x) {return x.id === id;});
         record = record || _.detect(this.to_write, function(x) {return x.id === id;});
@@ -944,9 +943,7 @@
         $.extend(cached.values, record.values);
         if (dirty)
             this.on_change();
-        var to_return = $.Deferred().then(callback);
-        to_return.resolve({result: true});
-        return to_return.promise();
+        return $.Deferred().resolve({result: true}).promise();
     },
     unlink: function(ids, callback, error_callback) {
         var self = this;
@@ -1092,9 +1089,9 @@
             return this._super.apply(this, arguments);
         }
     },
-    write: function (id, data, options, callback, error_callback) {
+    write: function (id, data, options) {
         if (this.write_function) {
-            return this.write_function(id, data, options, this._super).then(callback, error_callback);
+            return this.write_function(id, data, options, this._super);
         } else {
             return this._super.apply(this, arguments);
         }

=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js	2012-09-30 15:58:23 +0000
+++ addons/web/static/src/js/view_form.js	2012-10-01 09:21:50 +0000
@@ -3598,8 +3598,9 @@
         var pop = new instance.web.form.FormOpenPopup(self.o2m.view);
         pop.show_element(self.o2m.field.relation, id, self.o2m.build_context(), {
             title: _t("Open: ") + self.o2m.string,
+            
             write_function: function(id, data) {
-                return self.o2m.dataset.write(id, data, {}, function(r) {
+                return self.o2m.dataset.write(id, data, {}).then(function() {
                     self.o2m.reload_current_view();
                 });
             },

=== modified file 'addons/web_calendar/static/src/js/calendar.js'
--- addons/web_calendar/static/src/js/calendar.js	2012-09-30 14:45:28 +0000
+++ addons/web_calendar/static/src/js/calendar.js	2012-10-01 09:21:50 +0000
@@ -348,7 +348,7 @@
             index = this.dataset.get_id_index(event_id);
         if (index != null) {
             event_id = this.dataset.ids[index];
-            this.dataset.write(event_id, data, {}, function() {
+            this.dataset.write(event_id, data, {}).then(function() {
                 self.refresh_minical();
             });
         }

=== modified file 'addons/web_gantt/static/src/js/gantt.js'
--- addons/web_gantt/static/src/js/gantt.js	2012-09-04 14:11:55 +0000
+++ addons/web_gantt/static/src/js/gantt.js	2012-10-01 09:21:50 +0000
@@ -206,9 +206,7 @@
         } else { // we assume date_duration is defined
             data[self.fields_view.arch.attrs.date_delay] = duration;
         }
-        this.dataset.write(itask.id, data).then(function() {
-            console.log("task edited");
-        });
+        this.dataset.write(itask.id, data);
     },
     on_task_display: function(task) {
         var self = this;

=== modified file 'addons/web_kanban/static/src/js/kanban.js'
--- addons/web_kanban/static/src/js/kanban.js	2012-09-19 14:46:07 +0000
+++ addons/web_kanban/static/src/js/kanban.js	2012-10-01 09:21:50 +0000
@@ -379,7 +379,7 @@
             record.group = new_group;
             var data = {};
             data[this.group_by] = new_group.value;
-            this.dataset.write(record.id, data, {}, function() {
+            this.dataset.write(record.id, data, {}).then(function() {
                 record.do_reload();
                 new_group.do_save_sequences();
             }).fail(function(error, evt) {
@@ -877,7 +877,7 @@
                 var color_field = $(this).parents('.oe_kanban_colorpicker').first().data('field') || 'color';
                 var data = {};
                 data[color_field] = $(this).data('color');
-                self.view.dataset.write(self.id, data, {}, function() {
+                self.view.dataset.write(self.id, data, {}).then(function() {
                     self.record[color_field] = $(this).data('color');
                     self.do_reload();
                 });

=== modified file 'addons/web_view_editor/static/src/js/view_editor.js'
--- addons/web_view_editor/static/src/js/view_editor.js	2012-09-30 14:45:28 +0000
+++ addons/web_view_editor/static/src/js/view_editor.js	2012-10-01 09:21:50 +0000
@@ -775,7 +775,7 @@
                     convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml";', "");
                     convert_to_utf = '<?xml version="1.0"?>' + convert_to_utf;
                     arch.arch = convert_to_utf;
-                    this.dataset.write(this.one_object.clicked_tr_view[0] ,{"arch":convert_to_utf}, function(r) {});
+                    this.dataset.write(this.one_object.clicked_tr_view[0] ,{"arch":convert_to_utf});
                 } else {
                     this.dataset.unlink([this.one_object.clicked_tr_view[0]]);
                 }

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to