[fix] attempt to fix a race condition where a o2m will try to make a get_value on...
authorniv-openerp <nicolas.vanhoren@openerp.com>
Mon, 17 Oct 2011 16:22:28 +0000 (18:22 +0200)
committerniv-openerp <nicolas.vanhoren@openerp.com>
Mon, 17 Oct 2011 16:22:28 +0000 (18:22 +0200)
lp bug: https://launchpad.net/bugs/865048 fixed

bzr revid: nicolas.vanhoren@openerp.com-20111017162228-0xazc4zhd9dwj28k

addons/web/static/src/js/view_form.js

index b65194d..83e15bd 100644 (file)
@@ -1888,6 +1888,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({
     init: function(view, node) {
         this._super(view, node);
         this.is_started = $.Deferred();
+        this.is_setted = $.Deferred();
         this.form_last_update = $.Deferred();
         this.init_form_last_update = this.form_last_update;
         this.disable_utility_classes = true;
@@ -1952,9 +1953,11 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({
         this.viewmanager.on_mode_switch.add_first(function() {
             self.save_form_view();
         });
-        setTimeout(function () {
-            self.viewmanager.appendTo(self.$element);
-        }, 0);
+        this.is_setted.then(function() {
+            setTimeout(function () {
+                self.viewmanager.appendTo(self.$element);
+            }, 0);
+        });
     },
     reload_current_view: function() {
         var self = this;
@@ -2031,6 +2034,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({
         $.when(this.is_started).then(function() {
             self.reload_current_view();
         });
+        this.is_setted.resolve();
     },
     get_value: function() {
         var self = this;