From a6568345163fbcbd6f0e563952b976c47cc087a8 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 17 May 2011 11:59:23 +0200 Subject: [PATCH] [IMP] add ability to return a different object (than 'this') from Class.init, for factory-type scenarios bzr revid: xmo@openerp.com-20110517095923-8lr1pjelf94nwu44 --- addons/base/static/src/js/base.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/base/static/src/js/base.js b/addons/base/static/src/js/base.js index 19d608e0260..7ee9c947d1e 100644 --- a/addons/base/static/src/js/base.js +++ b/addons/base/static/src/js/base.js @@ -44,8 +44,11 @@ // The dummy class constructor function Class() { // All construction is actually done in the init method - if ( !initializing && this.init ) - this.init.apply(this, arguments); + if ( !initializing && this.init ) { + var ret = this.init.apply(this, arguments); + if (ret) { return ret; } + } + return this; } // Populate our constructed prototype object