diff options
| author | ima-openerp <ima@tinyerp.com> | 2013-10-21 18:12:22 +0530 |
|---|---|---|
| committer | ima-openerp <ima@tinyerp.com> | 2013-10-21 18:12:22 +0530 |
| commit | 7678ea996fbf0fcd146bd7ffbf75ab450db7dd4e (patch) | |
| tree | a854e1029302edfe582f594bc2f684aaeec9e45d /addons/web/static/src/js/openerpframework.js | |
| parent | 8acd61c43e7d47f3c83d19aa3c3f1d4fd4547c10 (diff) | |
| parent | ebeeae0ed4c57e36db143c11de11174ca1330892 (diff) | |
[MERGE]with trunk.
bzr revid: ima@tinyerp.com-20131021124222-7j3xc1ahtek5gyuw
Diffstat (limited to 'addons/web/static/src/js/openerpframework.js')
| -rw-r--r-- | addons/web/static/src/js/openerpframework.js | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/addons/web/static/src/js/openerpframework.js b/addons/web/static/src/js/openerpframework.js index 027452b42fb..ab10d304b30 100644 --- a/addons/web/static/src/js/openerpframework.js +++ b/addons/web/static/src/js/openerpframework.js @@ -138,6 +138,7 @@ var openerp = {}; throw new Error("You can only instanciate objects with the 'new' operator"); } // All construction is actually done in the init method + this._super = null; if (!initializing && this.init) { var ret = this.init.apply(this, arguments); if (ret) { return ret; } @@ -385,6 +386,14 @@ var Events = openerp.Class.extend({ } }); +/** + Mixin containing an event system. Events are also registered by specifying the target object + (the object which will receive the event when it is raised). Both the event-emitting object + and the target object store or reference to each other. This is used to correctly remove all + reference to the event handler when any of the object is destroyed (when the destroy() method + from ParentedMixin is called). Removing those references is necessary to avoid memory leak + and phantom events (events which are raised and sent to a previously destroyed object). +*/ openerp.EventDispatcherMixin = _.extend({}, openerp.ParentedMixin, { __eventDispatcherMixin: true, init: function() { @@ -808,7 +817,7 @@ var genericJsonRpc = function(fct_name, params, fct) { return result.result; } }, function() { - console.error("JsonRPC communication error", _.toArray(arguments)); + //console.error("JsonRPC communication error", _.toArray(arguments)); var def = $.Deferred(); return def.reject.apply(def, ["communication"].concat(_.toArray(arguments))); }); @@ -890,11 +899,29 @@ openerp.jsonpRpc = function(url, fct_name, params, settings) { }); // append the iframe to the DOM (will trigger the first load) $form.after($iframe); + if (settings.timeout) { + realSetTimeout(function() { + deferred.reject({}); + }, settings.timeout); + } return deferred; } }); }; +var realSetTimeout = function(fct, millis) { + var finished = new Date().getTime() + millis; + var wait = function() { + var current = new Date().getTime(); + if (current < finished) { + setTimeout(wait, finished - current); + } else { + fct(); + } + }; + setTimeout(wait, millis); +}; + openerp.Session = openerp.Class.extend(openerp.PropertiesMixin, { triggers: { 'request': 'Request sent', |
