Browse Source

[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
pull/1071/head
tarteo 6 years ago
committed by Dennis Sluijk
parent
commit
8f1a806b8e
  1. 67
      web_environment_ribbon/README.rst
  2. 4
      web_environment_ribbon/__init__.py
  3. 6
      web_environment_ribbon/__manifest__.py
  4. 2
      web_environment_ribbon/models/web_environment_ribbon_backend.py
  5. 8
      web_environment_ribbon/readme/CONFIGURE.rst
  6. 6
      web_environment_ribbon/readme/CONTRIBUTORS.rst
  7. 1
      web_environment_ribbon/readme/DESCRIPTION.rst
  8. 2
      web_environment_ribbon/readme/USAGE.rst
  9. 22
      web_environment_ribbon/static/src/js/ribbon.js

67
web_environment_ribbon/README.rst

@ -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
<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.
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 <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.

4
web_environment_ribbon/__init__.py

@ -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

6
web_environment_ribbon/__manifest__.py

@ -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
} }

2
web_environment_ribbon/models/web_environment_ribbon_backend.py

@ -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):

8
web_environment_ribbon/readme/CONFIGURE.rst

@ -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".

6
web_environment_ribbon/readme/CONTRIBUTORS.rst

@ -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>

1
web_environment_ribbon/readme/DESCRIPTION.rst

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

2
web_environment_ribbon/readme/USAGE.rst

@ -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

22
web_environment_ribbon/static/src/js/ribbon.js

@ -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 === "inherit") { return true; }
if (strToTest === "transparent") { return true; }
if (strToTest === "") {
return false;
}
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
});
Loading…
Cancel
Save