Hello everyone.
I have a model for which I need to set kanban box background color depending on the record "state".
The code is fine, but I cannot get the full kanban coloured background.
I am currently using Odoo 12 and found some samples for previous Odoo versions that's not working for this case.
On my py I have (besides other fields):
state = fields.Selection([('draft', 'New'),('to_start', 'Ready to Start'),('started', 'Started'),('confirm', 'Done')], string='Status', default='draft')
kanbancolor = fields.Integer('Color Index', compute="set_kanban_color")
def set_kanban_color(self):
for record in self:
kanbancolor = 0
if record.state == 'draft':
kanbancolor = 1
elif record.state == 'to_start':
kanbancolor = 2
elif record.state == 'started':
kanbancolor = 3
elif record.state == 'confirm':
kanbancolor = 4
else:
kanbancolor=5
record.kanbancolor = kanbancolor
On my xml file (only the kanban definition):
<kanban class="o_kanban_small_column" create="false" default_order="id desc">
<field name="name"/>
<field name="brand"/>
<field name="model"/>
<field name="kanbancolor"/>
<field name="state"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.kanbancolor.raw_value)}">
<div class="oe_kanban_global_click">
<div class="oe_kanban_details">
<strong class="o_kanban_record_title">
<p class="oe_centeralign">
<field name="name"/>
</p>
</strong>
<ul><li class="oe_centeralign"><strong>Brand:</strong> <field name="brand"/>  |  
<strong>Model:</strong> <field name="model"></field></li></ul>
</div>
</div>
</div>
</t>
</templates>
</kanban>
UPDATED: The code is running fine but instead of having the full background color, I only get a small bar at the left side of the kanban box.
How can I get a full background coloured kanban box?
Thank you all in advance
Did find any solution on this?
Hi @Nitin Kantak,
I did not find any solution for the "full background" color.
Thank you
PM