Browse Source
Merge pull request #796 from QubiQ/11.0-mig-web_environment_ribbon
Merge pull request #796 from QubiQ/11.0-mig-web_environment_ribbon
[11.0][MIG] web_environment_ribbonpull/801/merge
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 496 additions and 0 deletions
-
66web_environment_ribbon/README.rst
-
5web_environment_ribbon/__init__.py
-
27web_environment_ribbon/__manifest__.py
-
24web_environment_ribbon/data/ribbon_data.xml
-
39web_environment_ribbon/i18n/de.po
-
40web_environment_ribbon/i18n/fr.po
-
39web_environment_ribbon/i18n/hr.po
-
39web_environment_ribbon/i18n/nl_NL.po
-
39web_environment_ribbon/i18n/pt_BR.po
-
39web_environment_ribbon/i18n/sl.po
-
1web_environment_ribbon/models/__init__.py
-
37web_environment_ribbon/models/web_environment_ribbon_backend.py
-
BINweb_environment_ribbon/static/description/icon.png
-
BINweb_environment_ribbon/static/description/screenshot.png
-
28web_environment_ribbon/static/src/css/ribbon.css
-
55web_environment_ribbon/static/src/js/ribbon.js
-
18web_environment_ribbon/view/base_view.xml
@ -0,0 +1,66 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png |
||||
|
:target: https://www.gnu.org/licenses/agpl |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
====================== |
||||
|
Web Environment Ribbon |
||||
|
====================== |
||||
|
|
||||
|
Mark a Test Environment with a red ribbon on the top left corner in every page |
||||
|
|
||||
|
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/11.0 |
||||
|
|
||||
|
Bug Tracker |
||||
|
=========== |
||||
|
|
||||
|
Bugs are tracked on `GitHub Issues |
||||
|
<https://github.com/OCA/web/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 <cescoap@gmail.com> |
||||
|
* Javi Melendez <javimelex@gmail.com> |
||||
|
* Antonio Espinosa <antonio.espinosa@tecnativa.com> |
||||
|
* Thomas Binsfeld <thomas.binsfeld@acsone.eu> |
||||
|
* Xavier Jiménez <xavier.jimenez@qubiq.es> |
||||
|
|
||||
|
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. |
@ -0,0 +1,5 @@ |
|||||
|
# Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com> |
||||
|
# Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com> |
||||
|
# Copyright 2017 Thomas Binsfeld <thomas.binsfeld@acsone.eu> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
from . import models |
@ -0,0 +1,27 @@ |
|||||
|
# Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com> |
||||
|
# Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com> |
||||
|
# Copyright 2017 Thomas Binsfeld <thomas.binsfeld@acsone.eu> |
||||
|
# Copyright 2017 Xavier Jiménez <xavier.jimenez@qubiq.es> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
{ |
||||
|
'name': "Web Environment Ribbon", |
||||
|
'version': '11.0.1.0.0', |
||||
|
'category': 'Web', |
||||
|
'author': 'Francesco OpenCode Apruzzese, ' |
||||
|
'Tecnativa, ' |
||||
|
'Odoo Community Association (OCA)', |
||||
|
'website': 'https://github.com/OCA/web', |
||||
|
'license': 'AGPL-3', |
||||
|
"depends": [ |
||||
|
'web', |
||||
|
], |
||||
|
"data": [ |
||||
|
'view/base_view.xml', |
||||
|
'data/ribbon_data.xml', |
||||
|
], |
||||
|
"update_xml": [], |
||||
|
"demo_xml": [], |
||||
|
"auto_install": False, |
||||
|
'installable': True |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com> |
||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
||||
|
<odoo noupdate="1"> |
||||
|
|
||||
|
<!-- Add ribbon name default configuration parameter --> |
||||
|
<record id="default_ribbon_name" model="ir.config_parameter"> |
||||
|
<field name="key">ribbon.name</field> |
||||
|
<field name="value"><![CDATA[TEST<br/>({db_name})]]></field> |
||||
|
</record> |
||||
|
|
||||
|
<!-- Add ribbon color configuration parameter --> |
||||
|
<record id="set_ribbon_color" model="ir.config_parameter"> |
||||
|
<field name="key">ribbon.color</field> |
||||
|
<field name="value">#f0f0f0</field> |
||||
|
</record> |
||||
|
|
||||
|
<!-- Add ribbon background color configuration parameter --> |
||||
|
<record id="set_ribbon_background_color" model="ir.config_parameter"> |
||||
|
<field name="key">ribbon.background.color</field> |
||||
|
<field name="value">rgba(255,0,0,.6)</field> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
@ -0,0 +1,39 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * web_environment_ribbon |
||||
|
# |
||||
|
# Translators: |
||||
|
# Niki Waibel <niki.waibel@gmail.com>, 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 <niki.waibel@gmail.com>, 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 "" |
@ -0,0 +1,40 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * web_environment_ribbon |
||||
|
# |
||||
|
# Translators: |
||||
|
# OCA Transbot <transbot@odoo-community.org>, 2017 |
||||
|
# Quentin THEURET <odoo@kerpeo.com>, 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 <odoo@kerpeo.com>, 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" |
@ -0,0 +1,39 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * web_environment_ribbon |
||||
|
# |
||||
|
# Translators: |
||||
|
# Bole <bole@dajmi5.com>, 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 <bole@dajmi5.com>, 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 "" |
@ -0,0 +1,39 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * web_environment_ribbon |
||||
|
# |
||||
|
# Translators: |
||||
|
# Peter Hageman <hageman.p@gmail.com>, 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 <hageman.p@gmail.com>, 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 "" |
@ -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 <rmsolucoeseminformatic4@gmail.com>, 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 <rmsolucoeseminformatic4@gmail.com>, 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 "" |
@ -0,0 +1,39 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * web_environment_ribbon |
||||
|
# |
||||
|
# Translators: |
||||
|
# OCA Transbot <transbot@odoo-community.org>, 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 <transbot@odoo-community.org>, 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 "" |
@ -0,0 +1 @@ |
|||||
|
from . import web_environment_ribbon_backend |
@ -0,0 +1,37 @@ |
|||||
|
# 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'), |
||||
|
} |
After Width: 128 | Height: 128 | Size: 9.1 KiB |
After Width: 607 | Height: 198 | Size: 43 KiB |
@ -0,0 +1,28 @@ |
|||||
|
/* Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com> |
||||
|
Copyright 2017 Thomas Binsfeld <thomas.binsfeld@acsone.eu> |
||||
|
* 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; |
||||
|
} |
@ -0,0 +1,55 @@ |
|||||
|
/* Copyright 2015 Sylvain Calador <sylvain.calador@akretion.com> |
||||
|
Copyright 2015 Javi Melendez <javi.melendez@algios.com> |
||||
|
Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com> |
||||
|
Copyright 2017 Thomas Binsfeld <thomas.binsfeld@acsone.eu> |
||||
|
Copyright 2017 Xavier Jiménez <xavier.jimenez@qubiq.es> |
||||
|
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 rpc = require('web.rpc'); |
||||
|
var core = require('web.core'); |
||||
|
|
||||
|
// 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 = $('<div class="test-ribbon"/>'); |
||||
|
$('body').append(ribbon); |
||||
|
ribbon.hide(); |
||||
|
// Get ribbon data from backend
|
||||
|
rpc.query({ |
||||
|
model: 'web.environment.ribbon.backend', |
||||
|
method: '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
|
@ -0,0 +1,18 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- Copyright 2015 Francesco OpenCode Apruzzese <cescoap@gmail.com> |
||||
|
Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com> |
||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
||||
|
<odoo> |
||||
|
|
||||
|
<!-- Load css for ribbons --> |
||||
|
<template id="assets_backend" name="ribbon_test assets" |
||||
|
inherit_id="web.assets_backend"> |
||||
|
<xpath expr="." position="inside"> |
||||
|
<link rel="stylesheet" |
||||
|
href="/web_environment_ribbon/static/src/css/ribbon.css"/> |
||||
|
<script type="text/javascript" |
||||
|
src="/web_environment_ribbon/static/src/js/ribbon.js"/> |
||||
|
</xpath> |
||||
|
</template> |
||||
|
|
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue