From 32e420fd90a12adcc4b14894926ab4da77ba2272 Mon Sep 17 00:00:00 2001 From: Sylvain Calador Date: Thu, 17 Sep 2015 18:37:04 +0200 Subject: [PATCH] [IMP] web_environment_ribbon: conditional ribbon --- .../static/src/js/ribbon.js | 36 +++++++++++++++++++ web_environment_ribbon/view/base_view.xml | 1 + 2 files changed, 37 insertions(+) create mode 100644 web_environment_ribbon/static/src/js/ribbon.js diff --git a/web_environment_ribbon/static/src/js/ribbon.js b/web_environment_ribbon/static/src/js/ribbon.js new file mode 100644 index 00000000..6613bf45 --- /dev/null +++ b/web_environment_ribbon/static/src/js/ribbon.js @@ -0,0 +1,36 @@ +/****************************************************************************** + Copyright (C) 2015 Akretion (http://www.akretion.com) + @author Sylvain Calador + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +******************************************************************************/ + +openerp.web_environment_ribbon = function(instance) { + + var ribbon = $(document).find('.test-ribbon'); + ribbon.hide(); + + var model = new instance.web.Model('ir.config_parameter'); + var query = [['key', '=', 'ribbon.name']]; + var fields = ['value']; + + var res = model.call('search_read', [query, fields]).then( + function (result) { + if (result.length) { + ribbon.html(result[0].value); + ribbon.show(); + } + } + ); +} diff --git a/web_environment_ribbon/view/base_view.xml b/web_environment_ribbon/view/base_view.xml index 09a7caf4..62896be8 100644 --- a/web_environment_ribbon/view/base_view.xml +++ b/web_environment_ribbon/view/base_view.xml @@ -6,6 +6,7 @@