Browse Source

[ADD] OCA env ribbon + [FIX] for v9

pull/7/merge
Thibault Francois 9 years ago
parent
commit
7bbbc48c44
  1. 69
      web_environment_ribbon/README.rst
  2. 20
      web_environment_ribbon/__init__.py
  3. 40
      web_environment_ribbon/__openerp__.py
  4. 12
      web_environment_ribbon/data/ribbon_data.xml
  5. BIN
      web_environment_ribbon/static/description/icon.png
  6. BIN
      web_environment_ribbon/static/description/screenshot.png
  7. 24
      web_environment_ribbon/static/src/css/ribbon.css
  8. 35
      web_environment_ribbon/static/src/js/ribbon.js
  9. 21
      web_environment_ribbon/view/base_view.xml

69
web_environment_ribbon/README.rst

@ -0,0 +1,69 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
: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.
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
Known issues / Roadmap
======================
* Allow to define in some place (system parameter, configuration file...) the
ribbon color.
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
`here <https://github.com/OCA/web/issues/new?body=module:%20web_environment_ribbon%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Francesco Apruzzese <cescoap@gmail.com>
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 http://odoo-community.org.

20
web_environment_ribbon/__init__.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 Francesco OpenCode Apruzzese (<cescoap@gmail.com>)
# All Rights Reserved
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################

40
web_environment_ribbon/__openerp__.py

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 Francesco OpenCode Apruzzese (<cescoap@gmail.com>)
# All Rights Reserved
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': "Web Environment Ribbon",
'version': '8.0.0.1.0',
'category': 'Web',
'author': 'Francesco OpenCode Apruzzese,Odoo Community Association (OCA),Thibault Francois',
'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,
}

12
web_environment_ribbon/data/ribbon_data.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data 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">TEST</field>
</record>
</data>
</openerp>

BIN
web_environment_ribbon/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.1 KiB

BIN
web_environment_ribbon/static/description/screenshot.png

After

Width: 607  |  Height: 198  |  Size: 43 KiB

24
web_environment_ribbon/static/src/css/ribbon.css

@ -0,0 +1,24 @@
.test-ribbon{
width: 200px;
background: #e43;
position: absolute;
top: 50px;
left: -50px;
text-align: center;
line-height: 50px;
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: 1000;
position: fixed;
box-shadow: 0 0 3px rgba(0,0,0,.3);
background: rgba(255, 0, 0, .6);;
}
.test-ribbon b {
font-size: 20px;
}

35
web_environment_ribbon/static/src/js/ribbon.js

@ -0,0 +1,35 @@
/******************************************************************************
Copyright (C) 2015 Akretion (http://www.akretion.com)
@author Sylvain Calador <sylvain.calador@akretion.com>
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 <http://www.gnu.org/licenses/>.
******************************************************************************/
openerp.web_environment_ribbon = function(instance) {
var ribbon = $(document).find('.test-ribbon');
ribbon.hide();
var model = new instance.web.Model('ir.config_parameter');
var key = 'ribbon.name';
var res = model.call('get_param', [key]).then(
function (name) {
if (name && name != 'False') {
ribbon.html(name);
ribbon.show();
}
}
);
}

21
web_environment_ribbon/view/base_view.xml

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- 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>
<!-- Add ribbon to page -->
<template id="body_with_ribbon_test" name="ribbon_test web.webclient_bootstrap" inherit_id="web.webclient_bootstrap">
<xpath expr="//div[@class='openerp openerp_webclient_container oe_webclient']" position="before">
<div class="test-ribbon"/>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save