[ADD] key in manifest allowing auto loading of modules
bzr revid: chs@openerp.com-20110920154358-gpv2ahph6gbtlmiy
This commit is contained in:
parent
8cda63a6e8
commit
01eff42ca2
|
@ -2,6 +2,7 @@
|
|||
"name" : "web",
|
||||
"depends" : [],
|
||||
'active': True,
|
||||
'web_auto_load': True,
|
||||
'js' : [
|
||||
"static/lib/datejs/globalization/en-US.js",
|
||||
"static/lib/datejs/core.js",
|
||||
|
|
|
@ -104,7 +104,7 @@ home_template = textwrap.dedent("""<!DOCTYPE html>
|
|||
%(javascript)s
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var c = new openerp.init();
|
||||
var c = new openerp.init(%(modules)s);
|
||||
var wc = new c.web.WebClient("oe");
|
||||
wc.start();
|
||||
});
|
||||
|
@ -140,20 +140,26 @@ class WebClient(openerpweb.Controller):
|
|||
|
||||
@openerpweb.httprequest
|
||||
def home(self, req, s_action=None, **kw):
|
||||
modules = [a for a, m in openerpweb.addons_manifest.iteritems() if m.get('web_auto_load')]
|
||||
assert 'web' in modules
|
||||
cs_mods = ','.join(modules)
|
||||
|
||||
# script tags
|
||||
jslist = ['/web/webclient/js']
|
||||
jslist = ['/web/webclient/js?mods='+cs_mods]
|
||||
if req.debug:
|
||||
jslist = [i + '?debug=' + str(time.time()) for i in manifest_glob(req.config.addons_path, ['web'], 'js')]
|
||||
jslist = [i + '?debug=' + str(time.time()) for i in manifest_glob(req.config.addons_path, modules, 'js')]
|
||||
js = "\n ".join(['<script type="text/javascript" src="%s"></script>'%i for i in jslist])
|
||||
|
||||
# css tags
|
||||
csslist = ['/web/webclient/css']
|
||||
csslist = ['/web/webclient/css?mods='+cs_mods]
|
||||
if req.debug:
|
||||
csslist = [i + '?debug=' + str(time.time()) for i in manifest_glob(req.config.addons_path, ['web'], 'css')]
|
||||
csslist = [i + '?debug=' + str(time.time()) for i in manifest_glob(req.config.addons_path, modules, 'css')]
|
||||
css = "\n ".join(['<link rel="stylesheet" href="%s">'%i for i in csslist])
|
||||
|
||||
r = home_template % {
|
||||
'javascript': js,
|
||||
'css': css
|
||||
'css': css,
|
||||
'modules': repr(modules), # XXX good js-ification ?
|
||||
}
|
||||
return r
|
||||
|
||||
|
@ -342,7 +348,7 @@ class Session(openerpweb.Controller):
|
|||
# TODO query server for installed web modules
|
||||
mods = []
|
||||
for name, manifest in openerpweb.addons_manifest.items():
|
||||
if name != 'web' and manifest.get('active', True):
|
||||
if not manifest.get('web_auto_load') and manifest.get('active', True):
|
||||
mods.append(name)
|
||||
return mods
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
/**
|
||||
* OpenERP instance constructor
|
||||
*
|
||||
* @param {Boolean} skip_init if true, skips the built-in initialization
|
||||
* @param {Array} modules list of modules to initialize
|
||||
*/
|
||||
init: function(skip_init) {
|
||||
init: function(modules) {
|
||||
var new_instance = {
|
||||
// links to the global openerp
|
||||
_openerp: openerp,
|
||||
|
@ -35,9 +35,9 @@
|
|||
web_mobile: {}
|
||||
};
|
||||
openerp.sessions[new_instance._session_id] = new_instance;
|
||||
if (!skip_init){
|
||||
openerp.web(new_instance);
|
||||
}
|
||||
_.each(modules, function (element, index, list) {
|
||||
openerp[element](new_instance);
|
||||
});
|
||||
return new_instance;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -5,4 +5,5 @@
|
|||
"js": ["static/*/*.js", "static/*/js/*.js"],
|
||||
"css": [],
|
||||
'active': False,
|
||||
'web_auto_load': True,
|
||||
}
|
||||
|
|
|
@ -13,6 +13,13 @@ openerp.web.SearchView = openerp.web.SearchView.extend({
|
|||
|
||||
// here you may tweak globals object, if any, and play with on_* or do_* callbacks on them
|
||||
|
||||
openerp.web.Login = openerp.web.Login.extend({
|
||||
start: function() {
|
||||
console.log('Hello there');
|
||||
this._super.apply(this,arguments);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// vim:et fdc=0 fdl=0:
|
||||
|
|
Loading…
Reference in New Issue