From 0a6edac151d6d34b264735729d6575b399dc6455 Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Wed, 18 Nov 2015 15:26:43 +0100 Subject: [PATCH] [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 07fe5afc874b9527eac5408d9adc53a9a700aad3 which implemented the idea in a more limited way. Closes #9625 --- addons/web/controllers/main.py | 9 +++- addons/web/static/src/js/boot.js | 1 - addons/web/views/webclient_templates.xml | 1 + .../static/src/js/web_planner_common.js | 42 ++++++++++++------- .../static/src/xml/web_planner.xml | 8 +++- openerp/release.py | 4 +- 6 files changed, 45 insertions(+), 20 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 44e6bca6e4d..f0f455be1e3 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -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): diff --git a/addons/web/static/src/js/boot.js b/addons/web/static/src/js/boot.js index 65cf45827a0..77115499b46 100644 --- a/addons/web/static/src/js/boot.js +++ b/addons/web/static/src/js/boot.js @@ -51,7 +51,6 @@ testing: typeof QUnit === "object", debug: debug, remaining_jobs: jobs, - version: "community", __DEBUG__: { get_dependencies: function (name, transitive) { diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml index 2f066dc7c30..f0e455e95ce 100644 --- a/addons/web/views/webclient_templates.xml +++ b/addons/web/views/webclient_templates.xml @@ -308,6 +308,7 @@ require('web.core').csrf_token = token; require('qweb').default_dict.csrf_token = token; }); + odoo.db_info = ; <!--[if lte IE 9]> <![endif]--> diff --git a/addons/web_planner/static/src/js/web_planner_common.js b/addons/web_planner/static/src/js/web_planner_common.js index 58b2a72518a..f322c3a39ad 100644 --- a/addons/web_planner/static/src/js/web_planner_common.js +++ b/addons/web_planner/static/src/js/web_planner_common.js @@ -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, diff --git a/addons/web_planner/static/src/xml/web_planner.xml b/addons/web_planner/static/src/xml/web_planner.xml index 69f1d3e4df1..ce01833c3ea 100644 --- a/addons/web_planner/static/src/xml/web_planner.xml +++ b/addons/web_planner/static/src/xml/web_planner.xml @@ -33,7 +33,13 @@