diff --git a/addons/web/static/src/js/framework/widget.js b/addons/web/static/src/js/framework/widget.js index aae0ed36c19..ad68f4e9410 100644 --- a/addons/web/static/src/js/framework/widget.js +++ b/addons/web/static/src/js/framework/widget.js @@ -95,6 +95,16 @@ var Widget = core.Class.extend(mixins.PropertiesMixin, { // FIXME: this should not be this.setElement(this._make_descriptive()); }, + /** + * Method called between init and start. Performs asynchronous calls required by start. + * + * This method should return a Deferred which is resolved when start can be executed. + * + * @return {jQuery.Deferred} + */ + willStart: function() { + return $.when(); + }, /** * Destroys the current widget, also destroys all its children before destroying itself. */ @@ -162,9 +172,12 @@ var Widget = core.Class.extend(mixins.PropertiesMixin, { }, this), target); }, __widgetRenderAndInsert: function(insertion, target) { - this.renderElement(); - insertion(target); - return this.start(); + var self = this; + return this.willStart().then(function() { + self.renderElement(); + insertion(target); + return self.start(); + }); }, /** * Method called after rendering. Mostly used to bind actions, perform asynchronous