diff --git a/ext/custom-addons/dp_custom/models/ir_ui_menu.py b/ext/custom-addons/dp_custom/models/ir_ui_menu.py index e6dc3961..c8629de8 100644 --- a/ext/custom-addons/dp_custom/models/ir_ui_menu.py +++ b/ext/custom-addons/dp_custom/models/ir_ui_menu.py @@ -32,22 +32,21 @@ class ir_ui_menu(models.Model): _inherit = 'ir.ui.menu' @tools.ormcache(skiparg=2) - def get_disabled_menu_ids(self, cr, uid, context=None): - data_obj = self.pool.get('ir.model.data') - + def get_disabled_menu_ids(self): menu_ids = [] for menu in DISABLED_MENUS: - module, xml_id = menu.split('.') - menu = data_obj.get_object(cr, uid, module, xml_id) + menu = self.env.ref(menu) if menu: menu_ids.append(menu.id) return menu_ids - def _filter_visible_menus(self, cr, uid, ids, context=None): - if uid != 1: - disabled_ids = self.get_disabled_menu_ids(cr, uid) - ids = [id for id in ids if id not in disabled_ids] + @api.multi + def _filter_visible_menus(self): + if self.env.uid != 1: + disabled_ids = self.get_disabled_menu_ids() + ids = [id for id in self.ids if id not in disabled_ids] + self = self.browse(ids) - ids = super(ir_ui_menu, self)._filter_visible_menus(cr, uid, ids, context) + ids = super(ir_ui_menu, self)._filter_visible_menus() return ids diff --git a/ext/custom-addons/dp_max_width/__init__.py b/ext/custom-addons/dp_max_width/__init__.py new file mode 100755 index 00000000..487b990e --- /dev/null +++ b/ext/custom-addons/dp_max_width/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# datenpol gmbh +# Copyright (C) 2013-TODAY datenpol gmbh () +# +# 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 . +# +############################################################################## + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/ext/custom-addons/dp_max_width/__manifest__.py b/ext/custom-addons/dp_max_width/__manifest__.py new file mode 100755 index 00000000..da20972f --- /dev/null +++ b/ext/custom-addons/dp_max_width/__manifest__.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# datenpol gmbh +# Copyright (C) 2013-TODAY datenpol gmbh () +# +# 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 . +# +############################################################################## + + +{ + 'name': 'Max. Width for Form View', + 'category': 'Custom', + 'version': '1.0', + 'description': """ + """, + 'author': 'datenpol GmbH', + 'website': 'http://www.datenpol.at', + 'depends': [], + 'data': [ + 'views/max_width.xml', + ], + 'installable': True, + 'sequence': 150, + 'auto_install': False, +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/ext/custom-addons/dp_max_width/static/description/icon.png b/ext/custom-addons/dp_max_width/static/description/icon.png new file mode 100644 index 00000000..8387d765 Binary files /dev/null and b/ext/custom-addons/dp_max_width/static/description/icon.png differ diff --git a/ext/custom-addons/dp_max_width/static/src/css/max_width.css b/ext/custom-addons/dp_max_width/static/src/css/max_width.css new file mode 100644 index 00000000..a4458693 --- /dev/null +++ b/ext/custom-addons/dp_max_width/static/src/css/max_width.css @@ -0,0 +1,13 @@ +.o_followers .o_invite { + float: none !important; + display: block; + padding-left: 0px; +} + +.o_form_sheet { + max-width: 95% !important; +} + +.o_form_view .o_group.o_inner_group > tbody > tr > td.o_td_label { + min-width: 200px !important; +} diff --git a/ext/custom-addons/dp_max_width/views/max_width.xml b/ext/custom-addons/dp_max_width/views/max_width.xml new file mode 100644 index 00000000..4a819b1f --- /dev/null +++ b/ext/custom-addons/dp_max_width/views/max_width.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/ext/custom-addons/web_environment_ribbon/README.rst b/ext/custom-addons/web_environment_ribbon/README.rst new file mode 100644 index 00000000..f4f1edcc --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/README.rst @@ -0,0 +1,73 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +====================== +Web Environment Ribbon +====================== + +Mark a Test Environment with a red ribbon on the top left corner in every page + +.. image:: /web_environment_ribbon/static/description/screenshot.png + :alt: Screenshot + +Installation +============ + +No special setup + +Configuration +============= + +* You can change the ribbon's name ("TEST") by editing the default system + parameter "ribbon.name" (in the menu Settings > Parameters > System + Parameters) To hide the ribbon, set this parameter to "False" or delete it. +* You can customize the ribbon color and background color through system + parameters: "ribbon.color", "ribbon.background.color". Fill with valid CSS + colors or just set to "False" to use default values. +* You can add the database name in the ribbon by adding "{db_name}" in the + system parameter "ribbon.name". + +Usage +===== + +To use this module, you need only to install it. After installation, a red +ribbon will be visible on top left corner of every Odoo backend page + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/162/10.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Francesco Apruzzese +* Javi Melendez +* Antonio Espinosa +* Thomas Binsfeld + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/ext/custom-addons/web_environment_ribbon/__init__.py b/ext/custom-addons/web_environment_ribbon/__init__.py new file mode 100644 index 00000000..548366e6 --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Copyright 2015 Francesco OpenCode Apruzzese +# Copyright 2016 Antonio Espinosa +# Copyright 2017 Thomas Binsfeld +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import models diff --git a/ext/custom-addons/web_environment_ribbon/__manifest__.py b/ext/custom-addons/web_environment_ribbon/__manifest__.py new file mode 100644 index 00000000..f54195c8 --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/__manifest__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright 2015 Francesco OpenCode Apruzzese +# Copyright 2016 Antonio Espinosa +# Copyright 2017 Thomas Binsfeld +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': "Web Environment Ribbon", + 'version': '10.0.1.0.0', + 'category': 'Web', + 'author': 'Francesco OpenCode Apruzzese, ' + 'Tecnativa, ' + 'Odoo Community Association (OCA)', + 'website': 'https://it.linkedin.com/in/francescoapruzzese', + 'license': 'AGPL-3', + "depends": [ + 'web', + ], + "data": [ + 'view/base_view.xml', + 'data/ribbon_data.xml', + ], + "update_xml": [], + "demo_xml": [], + "auto_install": False, + 'installable': True +} diff --git a/ext/custom-addons/web_environment_ribbon/data/ribbon_data.xml b/ext/custom-addons/web_environment_ribbon/data/ribbon_data.xml new file mode 100644 index 00000000..0ba37985 --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/data/ribbon_data.xml @@ -0,0 +1,24 @@ + + + + + + + ribbon.name + ({db_name})]]> + + + + + ribbon.color + #f0f0f0 + + + + + ribbon.background.color + rgba(255,0,0,.6) + + + diff --git a/ext/custom-addons/web_environment_ribbon/i18n/de.po b/ext/custom-addons/web_environment_ribbon/i18n/de.po new file mode 100644 index 00000000..63ae96fb --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/i18n/de.po @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_environment_ribbon +# +# Translators: +# Niki Waibel , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-13 16:06+0000\n" +"PO-Revision-Date: 2017-07-13 16:06+0000\n" +"Last-Translator: Niki Waibel , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_display_name +msgid "Display Name" +msgstr "Anzeigename" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_id +msgid "ID" +msgstr "ID" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend___last_update +msgid "Last Modified on" +msgstr "" + +#. module: web_environment_ribbon +#: model:ir.model,name:web_environment_ribbon.model_web_environment_ribbon_backend +msgid "Web Environment Ribbon Backend" +msgstr "" diff --git a/ext/custom-addons/web_environment_ribbon/i18n/fr.po b/ext/custom-addons/web_environment_ribbon/i18n/fr.po new file mode 100644 index 00000000..9353a08c --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/i18n/fr.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_environment_ribbon +# +# Translators: +# OCA Transbot , 2017 +# Quentin THEURET , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-26 02:44+0000\n" +"PO-Revision-Date: 2017-07-26 02:44+0000\n" +"Last-Translator: Quentin THEURET , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_id +msgid "ID" +msgstr "ID" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend___last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: web_environment_ribbon +#: model:ir.model,name:web_environment_ribbon.model_web_environment_ribbon_backend +msgid "Web Environment Ribbon Backend" +msgstr "Backend du bandeau de l'environnement Web" diff --git a/ext/custom-addons/web_environment_ribbon/i18n/hr.po b/ext/custom-addons/web_environment_ribbon/i18n/hr.po new file mode 100644 index 00000000..0a98d335 --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/i18n/hr.po @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_environment_ribbon +# +# Translators: +# Bole , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-13 16:06+0000\n" +"PO-Revision-Date: 2017-07-13 16:06+0000\n" +"Last-Translator: Bole , 2017\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: hr\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_display_name +msgid "Display Name" +msgstr "Naziv za prikaz" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_id +msgid "ID" +msgstr "ID" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend___last_update +msgid "Last Modified on" +msgstr "Zadnje modificirano" + +#. module: web_environment_ribbon +#: model:ir.model,name:web_environment_ribbon.model_web_environment_ribbon_backend +msgid "Web Environment Ribbon Backend" +msgstr "" diff --git a/ext/custom-addons/web_environment_ribbon/i18n/nl_NL.po b/ext/custom-addons/web_environment_ribbon/i18n/nl_NL.po new file mode 100644 index 00000000..bf79a0ea --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/i18n/nl_NL.po @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_environment_ribbon +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-13 16:06+0000\n" +"PO-Revision-Date: 2017-07-13 16:06+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: nl_NL\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_display_name +msgid "Display Name" +msgstr "Weergavenaam" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_id +msgid "ID" +msgstr "ID" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend___last_update +msgid "Last Modified on" +msgstr "" + +#. module: web_environment_ribbon +#: model:ir.model,name:web_environment_ribbon.model_web_environment_ribbon_backend +msgid "Web Environment Ribbon Backend" +msgstr "" diff --git a/ext/custom-addons/web_environment_ribbon/i18n/pt_BR.po b/ext/custom-addons/web_environment_ribbon/i18n/pt_BR.po new file mode 100644 index 00000000..46eb9d7e --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/i18n/pt_BR.po @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_environment_ribbon +# +# Translators: +# Rodrigo de Almeida Sottomaior Macedo , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-13 16:06+0000\n" +"PO-Revision-Date: 2017-07-13 16:06+0000\n" +"Last-Translator: Rodrigo de Almeida Sottomaior Macedo , 2017\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_display_name +msgid "Display Name" +msgstr "Exibir Nome" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_id +msgid "ID" +msgstr "Identificação" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend___last_update +msgid "Last Modified on" +msgstr "Última Modificação em" + +#. module: web_environment_ribbon +#: model:ir.model,name:web_environment_ribbon.model_web_environment_ribbon_backend +msgid "Web Environment Ribbon Backend" +msgstr "" diff --git a/ext/custom-addons/web_environment_ribbon/i18n/sl.po b/ext/custom-addons/web_environment_ribbon/i18n/sl.po new file mode 100644 index 00000000..d07c1c5f --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/i18n/sl.po @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_environment_ribbon +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-13 16:06+0000\n" +"PO-Revision-Date: 2017-07-13 16:06+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_display_name +msgid "Display Name" +msgstr "" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend_id +msgid "ID" +msgstr "ID" + +#. module: web_environment_ribbon +#: model:ir.model.fields,field_description:web_environment_ribbon.field_web_environment_ribbon_backend___last_update +msgid "Last Modified on" +msgstr "" + +#. module: web_environment_ribbon +#: model:ir.model,name:web_environment_ribbon.model_web_environment_ribbon_backend +msgid "Web Environment Ribbon Backend" +msgstr "" diff --git a/ext/custom-addons/web_environment_ribbon/models/__init__.py b/ext/custom-addons/web_environment_ribbon/models/__init__.py new file mode 100644 index 00000000..18368b47 --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/models/__init__.py @@ -0,0 +1 @@ +from . import web_environment_ribbon_backend diff --git a/ext/custom-addons/web_environment_ribbon/models/web_environment_ribbon_backend.py b/ext/custom-addons/web_environment_ribbon/models/web_environment_ribbon_backend.py new file mode 100644 index 00000000..b6ba8c16 --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/models/web_environment_ribbon_backend.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import api, models + + +class WebEnvironmentRibbonBackend(models.AbstractModel): + + _name = 'web.environment.ribbon.backend' + _description = 'Web Environment Ribbon Backend' + + @api.model + def _prepare_ribbon_format_vals(self): + return { + 'db_name': self.env.cr.dbname, + } + + @api.model + def _prepare_ribbon_name(self): + name_tmpl = self.env['ir.config_parameter'].get_param('ribbon.name') + vals = self._prepare_ribbon_format_vals() + return name_tmpl.format(**vals) + + @api.model + def get_environment_ribbon(self): + """ + This method returns the ribbon data from ir config parameters + :return: dictionary + """ + ir_config_model = self.env['ir.config_parameter'] + name = self._prepare_ribbon_name() + return { + 'name': name, + 'color': ir_config_model.get_param('ribbon.color'), + 'background_color': ir_config_model.get_param( + 'ribbon.background.color'), + } diff --git a/ext/custom-addons/web_environment_ribbon/static/description/icon.png b/ext/custom-addons/web_environment_ribbon/static/description/icon.png new file mode 100644 index 00000000..78b52ae9 Binary files /dev/null and b/ext/custom-addons/web_environment_ribbon/static/description/icon.png differ diff --git a/ext/custom-addons/web_environment_ribbon/static/description/screenshot.png b/ext/custom-addons/web_environment_ribbon/static/description/screenshot.png new file mode 100644 index 00000000..30245656 Binary files /dev/null and b/ext/custom-addons/web_environment_ribbon/static/description/screenshot.png differ diff --git a/ext/custom-addons/web_environment_ribbon/static/src/css/ribbon.css b/ext/custom-addons/web_environment_ribbon/static/src/css/ribbon.css new file mode 100644 index 00000000..462cd2ff --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/static/src/css/ribbon.css @@ -0,0 +1,28 @@ +/* Copyright 2015 Francesco OpenCode Apruzzese + Copyright 2017 Thomas Binsfeld + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +.test-ribbon{ + width: 300px; + top: 25px; + left: -100px; + text-align: center; + padding: 10px; + line-height: 20px; + letter-spacing: 1px; + color: #f0f0f0; + -webkit-transform: rotate(-45deg); + -ms-transform: rotate(-45deg); + -moz-transform: rotate(-45deg); + -o-transform: rotate(-45deg); + transform: rotate(-45deg); + z-index: 9999; + position: fixed; + box-shadow: 0 0 3px rgba(0,0,0,.3); + background: rgba(255,0,0,.6); + pointer-events: none; +} + +.test-ribbon b { + font-size: 20px; +} diff --git a/ext/custom-addons/web_environment_ribbon/static/src/js/ribbon.js b/ext/custom-addons/web_environment_ribbon/static/src/js/ribbon.js new file mode 100644 index 00000000..2fe154a1 --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/static/src/js/ribbon.js @@ -0,0 +1,54 @@ +/* Copyright 2015 Sylvain Calador + Copyright 2015 Javi Melendez + Copyright 2016 Antonio Espinosa + Copyright 2017 Thomas Binsfeld + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +odoo.define('web_environment_ribbon.ribbon', function(require) { +"use strict"; + +var $ = require('jquery'); +var Model = require('web.Model'); +var core = require('web.core'); + +var backend_model = new Model('web.environment.ribbon.backend'); + +// Code from: http://jsfiddle.net/WK_of_Angmar/xgA5C/ +function validStrColour(strToTest) { + if (strToTest === "") { return false; } + if (strToTest === "inherit") { return true; } + if (strToTest === "transparent") { return true; } + var image = document.createElement("img"); + image.style.color = "rgb(0, 0, 0)"; + image.style.color = strToTest; + if (image.style.color !== "rgb(0, 0, 0)") { return true; } + image.style.color = "rgb(255, 255, 255)"; + image.style.color = strToTest; + return image.style.color !== "rgb(255, 255, 255)"; +} + +core.bus.on('web_client_ready', null, function () { + var ribbon = $('
'); + $('body').append(ribbon); + ribbon.hide(); + // Get ribbon data from backend + backend_model.call('get_environment_ribbon').then( + function (ribbon_data) { + // Ribbon name + if (ribbon_data.name && ribbon_data.name != 'False') { + ribbon.html(ribbon_data.name); + ribbon.show(); + } + // Ribbon color + if (ribbon_data.color && validStrColour(ribbon_data.color)) { + ribbon.css('color', ribbon_data.color); + } + // Ribbon background color + if (ribbon_data.background_color && validStrColour(ribbon_data.background_color)) { + ribbon.css('background-color', ribbon_data.background_color); + } + } + ); +}); + +}); // odoo.define diff --git a/ext/custom-addons/web_environment_ribbon/view/base_view.xml b/ext/custom-addons/web_environment_ribbon/view/base_view.xml new file mode 100644 index 00000000..f2a8d790 --- /dev/null +++ b/ext/custom-addons/web_environment_ribbon/view/base_view.xml @@ -0,0 +1,18 @@ + + + + + +