diff --git a/web_option_auto_color/README.rst b/web_option_auto_color/README.rst new file mode 100644 index 000000000..bb95448f4 --- /dev/null +++ b/web_option_auto_color/README.rst @@ -0,0 +1,54 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License + +Web Option Auto Color +===================== + +This module was written to offer a new autocolor attribute which can be used on +field in trees view. Using this attribute causes an identical coloration for +cells of the same value in a list view. + +Installation +============ + +To install this module, you need to: + + * Click on install button + + Usage + ===== + + In the view declaration, put autocolor="1" attribute in the field tag:: + + ... + + + ... + + + ... + + + ... + +Credits +======= + +Contributors +------------ + +* Stéphane Bidoul (ACSONE) +* Adrien Peiffer (ACSONE) + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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. \ No newline at end of file diff --git a/web_option_auto_color/__init__.py b/web_option_auto_color/__init__.py new file mode 100644 index 000000000..40a96afc6 --- /dev/null +++ b/web_option_auto_color/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/web_option_auto_color/__openerp__.py b/web_option_auto_color/__openerp__.py new file mode 100644 index 000000000..719c3a396 --- /dev/null +++ b/web_option_auto_color/__openerp__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This file is part of web_option_auto_color, +# an Odoo module. +# +# Copyright (c) 2015 ACSONE SA/NV () +# +# web_option_auto_color 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. +# +# web_option_auto_color 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 web_option_auto_color. +# If not, see . +# +############################################################################## +{ + 'name': "Web Option Auto Color", + 'author': "ACSONE SA/NV,Odoo Community Association (OCA)", + 'website': "http://acsone.eu", + 'category': 'web', + 'version': '0.1', + 'license': 'AGPL-3', + 'depends': [ + 'web', + ], + 'data': [ + 'views/web_option_auto_color.xml', + ], + 'qweb': [ + 'static/src/xml/templates.xml', + ], +} diff --git a/web_option_auto_color/static/src/js/view_list.js b/web_option_auto_color/static/src/js/view_list.js new file mode 100644 index 000000000..1cc6b1e33 --- /dev/null +++ b/web_option_auto_color/static/src/js/view_list.js @@ -0,0 +1,57 @@ +openerp.web_option_auto_color = function(instance) { + var _t = instance.web._t, + _lt = instance.web._lt; + var QWeb = instance.web.qweb; + + instance.web.ListView.include({ + + dh : function (n){ + var hex = (255-n).toString(16).toUpperCase(); + if (hex.length==1) { + hex='0'+hex; + } + return (hex); + }, + + inverse_color: function (couleur) { + + var r = /#?(\w{2})(\w{2})(\w{2})/i; + var splitH = r.exec(couleur); + + var ar=16*Number('0x'+splitH[1].slice(0,1))+Number('0x'+splitH[1].slice(1,2)); + var br=16*Number('0x'+splitH[2].slice(0,1))+Number('0x'+splitH[2].slice(1,2)); + var cr=16*Number('0x'+splitH[3].slice(0,1))+Number('0x'+splitH[3].slice(1,2)); + + return ('#'+this.dh(ar)+this.dh(br)+this.dh(cr)); + + }, + + get_seed_random_color: function(seed){ + color = Math.floor((Math.abs(Math.sin(seed) * 16777215)) % 16777215); + color = color.toString(16); + while(color.length < 6) { + color = '0' + color; + } + return '#' + color; + }, + + getIntValue: function(str){ + var sum = 0 + for (i=0; i + + + + this.attr('t-att-style', "column.autocolor == '1' and view.auto_color_cell_style(render_cell(record, column), column)") + + + diff --git a/web_option_auto_color/views/web_option_auto_color.xml b/web_option_auto_color/views/web_option_auto_color.xml new file mode 100644 index 000000000..a417cc818 --- /dev/null +++ b/web_option_auto_color/views/web_option_auto_color.xml @@ -0,0 +1,10 @@ + + + + + +