2011-08-11 03:10:00 +00:00
|
|
|
/*---------------------------------------------------------
|
|
|
|
* OpenERP Web Boostrap Code
|
|
|
|
*---------------------------------------------------------*/
|
2011-03-10 12:54:15 +00:00
|
|
|
|
2011-03-27 12:05:15 +00:00
|
|
|
/**
|
|
|
|
* @name openerp
|
2011-08-08 08:17:34 +00:00
|
|
|
* @namespace openerp
|
2011-03-27 12:05:15 +00:00
|
|
|
*/
|
2011-03-14 10:00:55 +00:00
|
|
|
(function() {
|
2013-08-06 08:58:12 +00:00
|
|
|
// copy everything in the openerp namespace to openerp.web
|
|
|
|
openerp.web = _.clone(openerp);
|
|
|
|
|
2013-07-26 12:15:14 +00:00
|
|
|
var inited = false;
|
2011-03-14 10:00:55 +00:00
|
|
|
|
2013-07-26 12:15:14 +00:00
|
|
|
_.extend(openerp, {
|
2011-03-16 23:56:34 +00:00
|
|
|
// Per session namespace
|
|
|
|
// openerp.<module> will map to
|
2012-04-26 22:25:52 +00:00
|
|
|
// openerp.instances.sessionname.<module> using a closure
|
2013-07-26 12:15:14 +00:00
|
|
|
instances: {instance0: openerp},
|
|
|
|
// links to the global openerp
|
|
|
|
_openerp: openerp,
|
|
|
|
// this unique id will be replaced by hostname_databasename by
|
|
|
|
// openerp.web.Session on the first connection
|
|
|
|
_session_id: "instance0",
|
2014-05-12 15:18:12 +00:00
|
|
|
_modules: openerp._modules || ['web'],
|
2013-07-26 12:15:14 +00:00
|
|
|
web_mobile: {},
|
2011-03-31 08:58:06 +00:00
|
|
|
/**
|
|
|
|
* OpenERP instance constructor
|
|
|
|
*
|
2012-10-26 08:45:43 +00:00
|
|
|
* @param {Array|String} modules list of modules to initialize
|
2011-03-31 08:58:06 +00:00
|
|
|
*/
|
2012-07-19 11:14:14 +00:00
|
|
|
init: function(modules) {
|
2014-05-12 15:18:12 +00:00
|
|
|
if (modules === undefined) {
|
|
|
|
modules = openerp._modules;
|
2012-10-26 08:45:43 +00:00
|
|
|
}
|
2013-08-07 09:54:57 +00:00
|
|
|
modules = _.without(modules, "web");
|
2013-07-26 12:15:14 +00:00
|
|
|
if (inited)
|
|
|
|
throw new Error("OpenERP was already inited");
|
|
|
|
inited = true;
|
2011-09-27 11:14:02 +00:00
|
|
|
for(var i=0; i < modules.length; i++) {
|
2013-07-26 12:15:14 +00:00
|
|
|
var fct = openerp[modules[i]];
|
|
|
|
if (typeof(fct) === "function") {
|
|
|
|
openerp[modules[i]] = {};
|
2013-07-29 09:25:12 +00:00
|
|
|
for (var k in fct) {
|
2013-07-26 12:15:14 +00:00
|
|
|
openerp[modules[i]][k] = fct[k];
|
|
|
|
}
|
|
|
|
fct(openerp, openerp[modules[i]]);
|
2012-08-12 22:29:01 +00:00
|
|
|
}
|
2011-07-08 12:26:49 +00:00
|
|
|
}
|
2013-07-26 12:15:14 +00:00
|
|
|
openerp._modules = ['web'].concat(modules);
|
|
|
|
return openerp;
|
2011-03-16 23:56:34 +00:00
|
|
|
}
|
2013-07-26 12:15:14 +00:00
|
|
|
});
|
|
|
|
})();
|
2011-03-10 12:54:15 +00:00
|
|
|
|