mirror of https://github.com/OCA/web.git
[ADD] web_context_in_colors
parent
11bd06e1bb
commit
77c90c1008
|
@ -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::
|
||||||
|
|
||||||
|
<filter name="paid_green" string="Show paid invoices in green" context="{'paid_should_be_green': True}" />
|
||||||
|
|
||||||
|
And then you could use::
|
||||||
|
|
||||||
|
<tree colors="green:state == 'paid' and context.get('paid_should_be_green')">
|
||||||
|
|
||||||
|
in your tree view. Take care here that the first match wins, so order your
|
||||||
|
color expressions accordingly.
|
||||||
|
|
||||||
|
Credits
|
||||||
|
=======
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Holger Brunn <hbrunn@therp.nl>
|
||||||
|
|
||||||
|
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.
|
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
|
@ -0,0 +1,37 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
|
||||||
|
#
|
||||||
|
# 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" : "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,
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
|
@ -0,0 +1,40 @@
|
||||||
|
//-*- coding: utf-8 -*-
|
||||||
|
//############################################################################
|
||||||
|
//
|
||||||
|
// OpenERP, Open Source Management Solution
|
||||||
|
// This module copyright (C) 2014 Therp BV (<http://therp.nl>).
|
||||||
|
//
|
||||||
|
// 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_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]);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
<template id="assets_backend" name="web_context_in_colors" inherit_id="web.assets_backend">
|
||||||
|
<xpath expr="." position="inside">
|
||||||
|
<script type="text/javascript" src="/web_context_in_colors/static/src/js/web_context_in_colors.js"></script>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</data>
|
||||||
|
</openerp>
|
Loading…
Reference in New Issue