[imp] implemented synchronized mode to be used in the o2m
bzr revid: nicolas.vanhoren@openerp.com-20111219161441-1117wec0btanqii2
This commit is contained in:
parent
95a3f10905
commit
10bd9f1aee
|
@ -462,6 +462,8 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
|
||||||
data: JSON.stringify(payload),
|
data: JSON.stringify(payload),
|
||||||
processData: false,
|
processData: false,
|
||||||
}, url);
|
}, url);
|
||||||
|
if (this.synch)
|
||||||
|
ajax.async = false;
|
||||||
return $.ajax(ajax);
|
return $.ajax(ajax);
|
||||||
},
|
},
|
||||||
rpc_jsonp: function(url, payload) {
|
rpc_jsonp: function(url, payload) {
|
||||||
|
@ -479,6 +481,8 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
|
||||||
cache: false,
|
cache: false,
|
||||||
data: data
|
data: data
|
||||||
}, url);
|
}, url);
|
||||||
|
if (this.synch)
|
||||||
|
ajax.async = false;
|
||||||
var payload_str = JSON.stringify(payload);
|
var payload_str = JSON.stringify(payload);
|
||||||
var payload_url = $.param({r:payload_str});
|
var payload_url = $.param({r:payload_str});
|
||||||
if(payload_url.length < 2000) {
|
if(payload_url.length < 2000) {
|
||||||
|
@ -805,7 +809,16 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
timer = setTimeout(waitLoop, CHECK_INTERVAL);
|
timer = setTimeout(waitLoop, CHECK_INTERVAL);
|
||||||
}
|
},
|
||||||
|
synchronized_mode: function(to_execute) {
|
||||||
|
var synch = this.synch;
|
||||||
|
this.synch = true;
|
||||||
|
try {
|
||||||
|
return to_execute();
|
||||||
|
} finally {
|
||||||
|
this.synch = synch;
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1220,6 +1233,15 @@ $.async_when = function() {
|
||||||
return def;
|
return def;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// special tweak for the web client
|
||||||
|
var old_async_when = $.async_when;
|
||||||
|
$.async_when = function() {
|
||||||
|
if (openerp.connection.synch)
|
||||||
|
return $.when.apply(this, arguments);
|
||||||
|
else
|
||||||
|
return old_async_when.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
|
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
|
||||||
|
|
|
@ -2221,27 +2221,27 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({
|
||||||
return commands['delete'](x.id);}));
|
return commands['delete'](x.id);}));
|
||||||
},
|
},
|
||||||
save_any_view: function() {
|
save_any_view: function() {
|
||||||
if (this.viewmanager && this.viewmanager.views && this.viewmanager.active_view &&
|
return this.session.synchronized_mode(_.bind(function() {
|
||||||
this.viewmanager.views[this.viewmanager.active_view] &&
|
if (this.viewmanager && this.viewmanager.views && this.viewmanager.active_view &&
|
||||||
this.viewmanager.views[this.viewmanager.active_view].controller) {
|
this.viewmanager.views[this.viewmanager.active_view] &&
|
||||||
var view = this.viewmanager.views[this.viewmanager.active_view].controller;
|
this.viewmanager.views[this.viewmanager.active_view].controller) {
|
||||||
if (this.viewmanager.active_view === "form") {
|
var view = this.viewmanager.views[this.viewmanager.active_view].controller;
|
||||||
var res = $.when(view.do_save());
|
if (this.viewmanager.active_view === "form") {
|
||||||
// it seems line there are some cases when this happens
|
var res = $.when(view.do_save());
|
||||||
/*if (!res.isResolved() && !res.isRejected()) {
|
if (!res.isResolved() && !res.isRejected()) {
|
||||||
console.warn("Asynchronous get_value() is not supported in form view.");
|
console.warn("Asynchronous get_value() is not supported in form view.");
|
||||||
}*/
|
}
|
||||||
return res;
|
return res;
|
||||||
} else if (this.viewmanager.active_view === "list") {
|
} else if (this.viewmanager.active_view === "list") {
|
||||||
var res = $.when(view.ensure_saved());
|
var res = $.when(view.ensure_saved());
|
||||||
// it seems line there are some cases when this happens
|
if (!res.isResolved() && !res.isRejected()) {
|
||||||
/*if (!res.isResolved() && !res.isRejected()) {
|
console.warn("Asynchronous get_value() is not supported in list view.");
|
||||||
console.warn("Asynchronous get_value() is not supported in list view.");
|
}
|
||||||
}*/
|
return res;
|
||||||
return res;
|
}
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
return false;
|
}, this));
|
||||||
},
|
},
|
||||||
is_valid: function() {
|
is_valid: function() {
|
||||||
this.validate();
|
this.validate();
|
||||||
|
|
Loading…
Reference in New Issue