3
0
Fork 0

[MIG] web_environment_ribbon: Migration to 12.0

[MIG] web_environment_ribbon: Migration to 12.0

[FIX] Default value for ribbon.name if not exists

[FIX] Hide ribbon when ribbon.name is false or not existing

[FIX] Remove copyright flag on __init__ files

[REM] Debugging logs

[REM] Make quotes inconsistant again and change sequence of data files in manifest
15.0-ocabot-merge-pr-2789-by-pedrobaeza-bump-patch
tarteo 2018-10-02 13:28:48 +02:00 committed by Andreas Perhab
parent f1cd9f50b9
commit 257c03b8e7
10 changed files with 99 additions and 49 deletions

View File

@ -1,13 +1,37 @@
.. 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 Web Environment Ribbon
====================== ======================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/11.0/web_environment_ribbon
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-11-0/web-11-0-web_environment_ribbon
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/11.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
Mark a Test Environment with a red ribbon on the top left corner in every page Mark a Test Environment with a red ribbon on the top left corner in every page
**Table of contents**
.. contents::
:local:
Configuration Configuration
============= =============
@ -26,41 +50,48 @@ Usage
To use this module, you need only to install it. After installation, a red 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 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 Bug Tracker
=========== ===========
Bugs are tracked on `GitHub Issues Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
<https://github.com/OCA/web/issues>`_. In case of trouble, please In case of trouble, please check there if your issue has already been reported.
check there if your issue has already been reported. If you spotted it first, If you spotted it first, help us smashing it by providing a detailed and welcomed
help us smashing it by providing a detailed and welcomed feedback. `feedback <https://github.com/OCA/web/issues/new?body=module:%20web_environment_ribbon%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits Credits
======= =======
Authors
~~~~~~~
* Francesco OpenCode Apruzzese
* Tecnativa
Contributors Contributors
------------ ~~~~~~~~~~~~
* Francesco Apruzzese <cescoap@gmail.com> * Francesco Apruzzese <cescoap@gmail.com>
* Javi Melendez <javimelex@gmail.com> * Javi Melendez <javimelex@gmail.com>
* Antonio Espinosa <antonio.espinosa@tecnativa.com> * Antonio Espinosa <antonio.espinosa@tecnativa.com>
* Thomas Binsfeld <thomas.binsfeld@acsone.eu> * Thomas Binsfeld <thomas.binsfeld@acsone.eu>
* Xavier Jiménez <xavier.jimenez@qubiq.es> * Xavier Jiménez <xavier.jimenez@qubiq.es>
* Dennis Sluijk <d.sluijk@onestein.nl>
Maintainer Maintainers
---------- ~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png .. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association :alt: Odoo Community Association
:target: https://odoo-community.org :target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
To contribute to this module, please visit https://odoo-community.org. This module is part of the `OCA/web <https://github.com/OCA/web/tree/11.0/web_environment_ribbon>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1,5 +1 @@
# 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 from . import models

View File

@ -6,7 +6,7 @@
{ {
'name': "Web Environment Ribbon", 'name': "Web Environment Ribbon",
'version': '11.0.1.0.2', 'version': '12.0.1.0.0',
'category': 'Web', 'category': 'Web',
'author': 'Francesco OpenCode Apruzzese, ' 'author': 'Francesco OpenCode Apruzzese, '
'Tecnativa, ' 'Tecnativa, '
@ -17,11 +17,9 @@
'web', 'web',
], ],
"data": [ "data": [
'view/base_view.xml',
'data/ribbon_data.xml', 'data/ribbon_data.xml',
'view/base_view.xml',
], ],
"update_xml": [],
"demo_xml": [],
"auto_install": False, "auto_install": False,
'installable': True 'installable': True
} }

View File

@ -3,22 +3,22 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1"> <odoo noupdate="1">
<!-- Add ribbon name default configuration parameter --> <!-- Add ribbon name default configuration parameter -->
<record id="default_ribbon_name" model="ir.config_parameter"> <record id="default_ribbon_name" model="ir.config_parameter">
<field name="key">ribbon.name</field> <field name="key">ribbon.name</field>
<field name="value"><![CDATA[TEST<br/>({db_name})]]></field> <field name="value"><![CDATA[TEST<br/>({db_name})]]></field>
</record> </record>
<!-- Add ribbon color configuration parameter --> <!-- Add ribbon color configuration parameter -->
<record id="set_ribbon_color" model="ir.config_parameter"> <record id="set_ribbon_color" model="ir.config_parameter">
<field name="key">ribbon.color</field> <field name="key">ribbon.color</field>
<field name="value">#f0f0f0</field> <field name="value">#f0f0f0</field>
</record> </record>
<!-- Add ribbon background color configuration parameter --> <!-- Add ribbon background color configuration parameter -->
<record id="set_ribbon_background_color" model="ir.config_parameter"> <record id="set_ribbon_background_color" model="ir.config_parameter">
<field name="key">ribbon.background.color</field> <field name="key">ribbon.background.color</field>
<field name="value">rgba(255,0,0,.6)</field> <field name="value">rgba(255,0,0,.6)</field>
</record> </record>
</odoo> </odoo>

View File

@ -20,7 +20,7 @@ class WebEnvironmentRibbonBackend(models.AbstractModel):
name_tmpl = self.env['ir.config_parameter'].sudo().get_param( name_tmpl = self.env['ir.config_parameter'].sudo().get_param(
'ribbon.name') 'ribbon.name')
vals = self._prepare_ribbon_format_vals() vals = self._prepare_ribbon_format_vals()
return name_tmpl.format(**vals) return name_tmpl and name_tmpl.format(**vals) or name_tmpl
@api.model @api.model
def get_environment_ribbon(self): def get_environment_ribbon(self):

View File

@ -0,0 +1,8 @@
* 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".

View File

@ -0,0 +1,6 @@
* 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>
* Dennis Sluijk <d.sluijk@onestein.nl>

View File

@ -0,0 +1 @@
Mark a Test Environment with a red ribbon on the top left corner in every page

View File

@ -0,0 +1,2 @@
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

View File

@ -14,20 +14,28 @@ odoo.define('web_environment_ribbon.ribbon', function(require) {
// Code from: http://jsfiddle.net/WK_of_Angmar/xgA5C/ // Code from: http://jsfiddle.net/WK_of_Angmar/xgA5C/
function validStrColour(strToTest) { function validStrColour(strToTest) {
if (strToTest === "") { return false; } if (strToTest === "") {
if (strToTest === "inherit") { return true; } return false;
if (strToTest === "transparent") { return true; } }
if (strToTest === "inherit") {
return true;
}
if (strToTest === "transparent") {
return true;
}
var image = document.createElement("img"); var image = document.createElement("img");
image.style.color = "rgb(0, 0, 0)"; image.style.color = "rgb(0, 0, 0)";
image.style.color = strToTest; image.style.color = strToTest;
if (image.style.color !== "rgb(0, 0, 0)") { return true; } if (image.style.color !== "rgb(0, 0, 0)") {
return true;
}
image.style.color = "rgb(255, 255, 255)"; image.style.color = "rgb(255, 255, 255)";
image.style.color = strToTest; image.style.color = strToTest;
return image.style.color !== "rgb(255, 255, 255)"; return image.style.color !== "rgb(255, 255, 255)";
} }
core.bus.on('web_client_ready', null, function () { core.bus.on('web_client_ready', null, function () {
var ribbon = $('<div class="test-ribbon"/>'); var ribbon = $('<div class="test-ribbon hidden"/>');
$('body').append(ribbon); $('body').append(ribbon);
ribbon.hide(); ribbon.hide();
// Get ribbon data from backend // Get ribbon data from backend
@ -37,7 +45,7 @@ odoo.define('web_environment_ribbon.ribbon', function(require) {
}).then( }).then(
function (ribbon_data) { function (ribbon_data) {
// Ribbon name // Ribbon name
if (ribbon_data.name && ribbon_data.name != 'False') { if (ribbon_data.name && ribbon_data.name !== 'False') {
ribbon.html(ribbon_data.name); ribbon.html(ribbon_data.name);
ribbon.show(); ribbon.show();
} }
@ -52,4 +60,4 @@ odoo.define('web_environment_ribbon.ribbon', function(require) {
} }
); );
}); });
}); // odoo.define });