diff --git a/web_context_in_colors/README.rst b/web_context_in_colors/README.rst new file mode 100644 index 00000000..eb8eb15b --- /dev/null +++ b/web_context_in_colors/README.rst @@ -0,0 +1,43 @@ +Context in colors +================= + +This addon allows to use the current context in colors, thereby allowing i.e. +search filters changing the colors used in a tree view. This also works for +the fonts attribute. + +Usage +===== + +You might define a search filter:: + + + +And then you could use:: + + + +in your tree view. Take care here that the first match wins, so order your +color expressions accordingly. + +Credits +======= + +Contributors +------------ + +* Holger Brunn + +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. diff --git a/web_context_in_colors/__init__.py b/web_context_in_colors/__init__.py new file mode 100644 index 00000000..9dd152f9 --- /dev/null +++ b/web_context_in_colors/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# 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 . +# +############################################################################## diff --git a/web_context_in_colors/__openerp__.py b/web_context_in_colors/__openerp__.py new file mode 100644 index 00000000..68a9e06f --- /dev/null +++ b/web_context_in_colors/__openerp__.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# 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 . +# +############################################################################## +{ + "name" : "Context in colors and fonts", + "summary": "Use the context in a tree view's colors and fonts attribute", + "version" : "1.1", + "author" : "Therp BV", + "complexity": "normal", + "category" : "Dependency", + "depends" : [ + 'web', + ], + "data": [ + 'view/qweb.xml', + ], + "auto_install": False, + "installable": True, + "application": False, +} diff --git a/web_context_in_colors/static/description/icon.png b/web_context_in_colors/static/description/icon.png new file mode 100644 index 00000000..f1006195 Binary files /dev/null and b/web_context_in_colors/static/description/icon.png differ diff --git a/web_context_in_colors/static/src/js/web_context_in_colors.js b/web_context_in_colors/static/src/js/web_context_in_colors.js new file mode 100644 index 00000000..a753cfa6 --- /dev/null +++ b/web_context_in_colors/static/src/js/web_context_in_colors.js @@ -0,0 +1,40 @@ +//-*- coding: utf-8 -*- +//############################################################################ +// +// OpenERP, Open Source Management Solution +// This module copyright (C) 2014 Therp BV (). +// +// 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 . +// +//############################################################################ + +openerp.web_context_in_colors = function(instance) +{ + instance.web.ListView.include( + { + style_for: function (record) + { + var record_with_context = { + attributes: _.extend({}, record.attributes || {}), + }; + if(!record_with_context.attributes.context) + { + record_with_context.attributes.context = py.dict.fromJSON( + instance.web.pyeval.eval( + 'context', this.dataset.get_context())); + } + return this._super.apply(this, [record_with_context]); + }, + }); +} diff --git a/web_context_in_colors/view/qweb.xml b/web_context_in_colors/view/qweb.xml new file mode 100644 index 00000000..2f09fe77 --- /dev/null +++ b/web_context_in_colors/view/qweb.xml @@ -0,0 +1,10 @@ + + + + + +