[FIX] web, openerp: make the webclient edition aware

- Differentiate between the Community and Enterprise editions
in the version number. By adding this attribute on the global
odoo JS object in the web client bootstrap controller /web,
we can differentiate between versions easily on the client
side without extra RPC calls.

- Remove a couple of version-related RPC calls in case
the global version info is present in the JS environment

- Update "About" panel to display the edition info

- This commit also reverts 07fe5afc87
which implemented the idea in a more limited way.

Closes #9625
This commit is contained in:
Damien Bouvy
2015-11-25 18:12:42 +01:00
committed by Olivier Dony
parent e8e5405d0c
commit 0a6edac151
6 changed files with 45 additions and 20 deletions
+8 -1
View File
@@ -513,6 +513,13 @@ def binary_content(xmlid=None, model='ir.attachment', id=None, field='datas', un
return (status, headers, content)
def db_info():
version_info = openerp.service.common.exp_version()
return {
'server_version': version_info.get('server_version'),
'server_version_info': version_info.get('server_version_info'),
}
#----------------------------------------------------------
# OpenERP Web web Controllers
#----------------------------------------------------------
@@ -533,7 +540,7 @@ class Home(http.Controller):
request.uid = request.session.uid
menu_data = request.registry['ir.ui.menu'].load_menus(request.cr, request.uid, request.debug, context=request.context)
return request.render('web.webclient_bootstrap', qcontext={'menu_data': menu_data})
return request.render('web.webclient_bootstrap', qcontext={'menu_data': menu_data, 'db_info': json.dumps(db_info())})
@http.route('/web/dbredirect', type='http', auth="none")
def web_db_redirect(self, redirect='/', **kw):
-1
View File
@@ -51,7 +51,6 @@
testing: typeof QUnit === "object",
debug: debug,
remaining_jobs: jobs,
version: "community",
__DEBUG__: {
get_dependencies: function (name, transitive) {
+1
View File
@@ -308,6 +308,7 @@
require('web.core').csrf_token = token;
require('qweb').default_dict.csrf_token = token;
});
odoo.db_info = <t t-raw="db_info"/>;
</script>
<t t-call-assets="web.assets_backend"/>
&lt;!--[if lte IE 9]&gt; <link rel="stylesheet" href="/web/static/src/css/ie.css"/> &lt;![endif]--&gt;
@@ -417,29 +417,41 @@ var PlannerHelpMixin = {
var menu = $(ev.currentTarget).data('menu');
if (menu === 'about') {
var self = this;
self.rpc("/web/webclient/version_info", {}).done(function(res) {
var $help = $(QWeb.render("PlannerLauncher.about", {version_info: res}));
$help.find('a.oe_activate_debug_mode').click(function (e) {
e.preventDefault();
window.location = $.param.querystring( window.location.href, 'debug');
if (!odoo.db_info) {
var self = this;
this.rpc("/web/webclient/version_info", {}).done(function(db_info) {
self.on_menu_help_about(db_info);
});
new Dialog(this, {
size: 'medium',
dialogClass: 'o_act_window',
title: _t("About"),
$content: $help
}).open();
});
} else {
this.on_menu_help_about(odoo.db_info);
}
} else if (menu === 'documentation') {
window.open('https://www.odoo.com/documentation/user', '_blank');
} else if (menu === 'planner') {
if (this.dialog) this.show_dialog();
} else if (menu === 'support') {
window.open('https://www.odoo.com/buy', '_blank');
if (odoo.db_info && odoo.db_info.server_version_info[5] === 'c') {
window.open('https://www.odoo.com/buy', '_blank');
} else {
window.location.href = 'mailto:help@odoo.com';
}
}
},
}
on_menu_help_about: function(db_info) {
var $help = $(QWeb.render("PlannerLauncher.about", {db_info: db_info}));
$help.find('a.oe_activate_debug_mode').click(function (e) {
e.preventDefault();
window.location = $.param.querystring( window.location.href, 'debug');
});
new Dialog(this, {
size: 'medium',
dialogClass: 'o_act_window',
title: _t("About"),
$content: $help
}).open();
},
};
return {
PlannerDialog: PlannerDialog,
@@ -33,7 +33,13 @@
</div>
<div class="user-info-block">
<div class="user-heading">
<h3>Version <t t-esc="version_info.server_version"/></h3>
<h3>
Version <t t-esc="db_info.server_version"/>
(<span t-esc="db_info.server_version_info[5] == 'e'?'Enterprise':'Community'"/> Edition)
</h3>
<t t-if="db_info.expiration_date">
<h5>Database expiration: <t t-esc="new moment(db_info.expiration_date).format('LL')"/></h5>
</t>
</div>
<div class="user-body">
<div class="tab-content">
+2 -2
View File
@@ -12,8 +12,8 @@ RELEASE_LEVELS_DISPLAY = {ALPHA: ALPHA,
# properly comparable using normal operarors, for example:
# (6,1,0,'beta',0) < (6,1,0,'candidate',1) < (6,1,0,'candidate',2)
# (6,1,0,'candidate',2) < (6,1,0,'final',0) < (6,1,2,'final',0)
version_info = (9, 0, 0, FINAL, 0)
version = '.'.join(map(str, version_info[:2])) + RELEASE_LEVELS_DISPLAY[version_info[3]] + str(version_info[4] or '')
version_info = (9, 0, 0, FINAL, 0, 'c')
version = '.'.join(map(str, version_info[:2])) + RELEASE_LEVELS_DISPLAY[version_info[3]] + str(version_info[4] or '') + version_info[5]
series = serie = major_version = '.'.join(map(str, version_info[:2]))
product_name = 'Odoo'