Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

kanban attribute : How to change the color

By
Mind And Go
on 7/12/13, 10:16 AM 4,890 views

Hy folks,

I was wondering how is possible to change the background color of an item in the same way as for tree, calendar, etc... I tried this :

<kanban position="attributes">
<attribute name="colors">green:membership_state='none';red:membership_state</attribute></kanban>

How is it possible to condition color? Where can I found example of this in the mdoules?

Thanks

Hi, Any luck? Having the same question. Many thanks!

Mihai Marius
on 1/14/14, 11:13 AM
0
Mind And Go
On 5/27/14, 5:12 PM

Changing the color in kanban could be done by setting a class like that :

<code>
<field name="member_color"/>
.../...
<templates>
.../...
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.member_color.raw_value)}" >
.../...
</div>
</code>

I created a functionnl field :
```python
'member_color': fields.function(_check_color, 'Couleur', type="integer")
.../...
def _check_color(self, cr, uid, ids, field_name, arg, context):
        pp = pprint.PrettyPrinter(indent=4)
        res = {}       
        for record in self.browse(cr, uid, ids, context):
            color = 0
            if record.membership_state == u'paid':
                color = 4
            elif record.membership_state == u'invoiced':
                color = 3
            elif record.membership_state == u'canceled':
                color = 3
            elif record.membership_state == u'waiting':
                color = 5
            elif record.membership_state == u'old':
                color= 1
            res[record.id] = color
        return res

```

The principle is that the web  widget that handle Kanban will load the color thanks to its css. Check ".openerp .oe_kanban_view .oe_kanban_color_X" css classes in the web css.
AFAIK The color number is limited to 0->9 caus the js method is designed like this.

Hope it could help
 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 7/12/13, 10:16 AM
Seen: 4890 times
Last updated: 3/16/15, 8:10 AM