summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/boot.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/boot.js')
-rw-r--r--addons/web/static/src/js/boot.js75
1 files changed, 41 insertions, 34 deletions
diff --git a/addons/web/static/src/js/boot.js b/addons/web/static/src/js/boot.js
index 4565d220dc8..c255db36ff8 100644
--- a/addons/web/static/src/js/boot.js
+++ b/addons/web/static/src/js/boot.js
@@ -7,15 +7,20 @@
* @namespace openerp
*/
(function() {
- if (this.openerp)
- return;
- var session_counter = 0;
+ var inited = false;
- var openerp = this.openerp = {
+ _.extend(openerp, {
// Per session namespace
// openerp.<module> will map to
// openerp.instances.sessionname.<module> using a closure
- instances: {},
+ 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",
+ _modules: ['web'],
+ web_mobile: {},
/**
* OpenERP instance constructor
*
@@ -24,41 +29,43 @@
init: function(modules) {
if (modules === null) {
modules = [];
- } else {
- modules = _.union(['web'], modules || []);
}
- var new_instance = {
- // 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: "instance" + session_counter++,
- _modules: modules,
- web: {},
- web_mobile: {}
- };
- openerp.instances[new_instance._session_id] = new_instance;
+ if (inited)
+ throw new Error("OpenERP was already inited");
+ inited = true;
+ init_web_modules();
for(var i=0; i < modules.length; i++) {
- new_instance[modules[i]] = {};
- if (openerp[modules[i]]) {
- openerp[modules[i]](new_instance,new_instance[modules[i]]);
+ if (modules[i] === "web")
+ continue;
+ var fct = openerp[modules[i]];
+ if (typeof(fct) === "function") {
+ openerp[modules[i]] = {};
+ for (k in fct) {
+ openerp[modules[i]][k] = fct[k];
+ }
+ fct(openerp, openerp[modules[i]]);
}
}
- return new_instance;
+ openerp._modules = ['web'].concat(modules);
+ return openerp;
}
- };
-})();
+ });
-/*---------------------------------------------------------
- * OpenERP Web web module split
- *---------------------------------------------------------*/
-openerp.web = function(session) {
- var files = ["pyeval", "corelib","coresetup","dates","formats","chrome","data","views","search","list","form","list_editable","web_mobile","view_tree","data_export","data_import"];
- for(var i=0; i<files.length; i++) {
- if(openerp.web[files[i]]) {
- openerp.web[files[i]](session);
+ /*---------------------------------------------------------
+ * OpenERP Web web module split
+ *---------------------------------------------------------*/
+ function init_web_modules() {
+ var files = ["pyeval", "corelib","coresetup","dates","formats","chrome","data","views","search","list","form","list_editable","web_mobile","view_tree","data_export","data_import"];
+ for(var i=0; i<files.length; i++) {
+ var fct = openerp.web[files[i]];
+ if(typeof(fct) === "function") {
+ openerp.web[files[i]] = {};
+ for (k in fct) {
+ openerp.web[files[i]][k] = fct[k];
+ }
+ fct(openerp, openerp.web[files[i]]);
+ }
}
}
-};
+})();
-// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: