data: JSON.stringify(payload),
processData: false,
}, url);
+ if (this.synch)
+ ajax.async = false;
return $.ajax(ajax);
},
rpc_jsonp: function(url, payload) {
cache: false,
data: data
}, url);
+ if (this.synch)
+ ajax.async = false;
var payload_str = JSON.stringify(payload);
var payload_url = $.param({r:payload_str});
if(payload_url.length < 2000) {
}
};
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;
+ }
+ },
});
/**
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:
return commands['delete'](x.id);}));
},
save_any_view: function() {
- if (this.viewmanager && this.viewmanager.views && this.viewmanager.active_view &&
- this.viewmanager.views[this.viewmanager.active_view] &&
- this.viewmanager.views[this.viewmanager.active_view].controller) {
- var view = this.viewmanager.views[this.viewmanager.active_view].controller;
- if (this.viewmanager.active_view === "form") {
- var res = $.when(view.do_save());
- // it seems line there are some cases when this happens
- /*if (!res.isResolved() && !res.isRejected()) {
- console.warn("Asynchronous get_value() is not supported in form view.");
- }*/
- return res;
- } else if (this.viewmanager.active_view === "list") {
- var res = $.when(view.ensure_saved());
- // it seems line there are some cases when this happens
- /*if (!res.isResolved() && !res.isRejected()) {
- console.warn("Asynchronous get_value() is not supported in list view.");
- }*/
- return res;
- }
- }
- return false;
+ return this.session.synchronized_mode(_.bind(function() {
+ if (this.viewmanager && this.viewmanager.views && this.viewmanager.active_view &&
+ this.viewmanager.views[this.viewmanager.active_view] &&
+ this.viewmanager.views[this.viewmanager.active_view].controller) {
+ var view = this.viewmanager.views[this.viewmanager.active_view].controller;
+ if (this.viewmanager.active_view === "form") {
+ var res = $.when(view.do_save());
+ if (!res.isResolved() && !res.isRejected()) {
+ console.warn("Asynchronous get_value() is not supported in form view.");
+ }
+ return res;
+ } else if (this.viewmanager.active_view === "list") {
+ var res = $.when(view.ensure_saved());
+ if (!res.isResolved() && !res.isRejected()) {
+ console.warn("Asynchronous get_value() is not supported in list view.");
+ }
+ return res;
+ }
+ }
+ return false;
+ }, this));
},
is_valid: function() {
this.validate();