βΆοΈ Introduction
Kanban views are an essential visual interface in Odoo β used for pipelines, tasks, projects, leads, tickets, and more. But the default Kanban cards are basic. What if you want cards that:
β Change colour based on record data (e.g., status or priority)
β Respond to clicks with custom actions
β Display additional dynamic information
In this tutorial, weβll show you how to build a custom Kanban card in Odoo 19 that supports dynamic colour highlighting and clickable behaviour β making your Kanban boards more interactive and user-friendly.
π₯ Watch the full video:
Β
π What Youβll Learn
By the end of this guide, you will know how to:
β Extend an existing Kanban view in Odoo
β Add dynamic styling based on record fields
β Make Kanban cards clickable to open records or trigger actions
β Write clean XML and optional JavaScript for UI logic
π Step-by-Step Implementation
πΉ 1. Create Your Custom Module
Start with a custom module β for example kanban_color_action. The structure typically looks like:
kanban_color_action/ βββ __init__.py βββ __manifest__.py βββ models/ β βββ __init__.py βββ views/ β βββ kanban_color_views.xml
In your manifest (__manifest__.py), include the views file:
{ 'name': 'Kanban Custom Color & Action', 'version': '1.0', 'depends': ['base', 'project'], 'data': ['views/kanban_color_views.xml'], }
πΉ 2. Add Custom Fields (Optional)
If needed, add custom fields to the model youβre enhancing. For example, a priority_level field on tasks:
from odoo import models, fields class ProjectTask(models.Model): _inherit = 'project.task' priority_level = fields.Selection([ ('low', 'Low'), ('medium', 'Medium'), ('high', 'High'), ], default='low')
This field will be used to adjust colours dynamically.
πΉ 3. Override the Kanban View
In views/kanban_color_views.xml, extend the existing Kanban template and use conditional classes:
<record id="view_task_kanban_custom" model="ir.ui.view"> <field name="name">project.task.kanban.custom</field> <field name="model">project.task</field> <field name="inherit_id" ref="project.view_task_kanban"/> <field name="arch" type="xml"> <templates> <t t-name="kanban-box"> <div t-classes="[ 'oe_kanban_global_click', record.priority_level.value == 'high' and 'bg-danger' or '', record.priority_level.value == 'medium' and 'bg-warning' or '', record.priority_level.value == 'low' and 'bg-success' or '' ]"> <div class="oe_kanban_card_body"> <strong><t t-esc="record.name.value"/></strong> </div> </div> </t> </templates> </field> </record>
This template:
β Inherits the existing Kanban
β Adds CSS classes based on priority_level
β Applies Bootstrap colours like bg-danger, bg-warning, bg-success
πΉ 4. Enable Clickable Behaviour
To make the Kanban cards open the form view on click, you can add:
<kanban class="o_kanban_example" js_class="KanbanController" data-widget="kanban_record_clickable"> </kanban>
This instructs Odoo to treat the card as clickable β opening the target recordβs form view.
You can also tie more advanced JavaScript actions if needed.
πΉ 5. Add Custom CSS (Optional)
If you want more control over styling beyond colors, include a CSS file:
.kanban_high { border: 2px solid #d9534f; font-weight: bold; } .kanban_low { background-color: #d4edda; }
Include this CSS in your moduleβs static assets.
π§ Tips & Best Practices
β Dynamic fields like priority, state, or deadlines work well for colour logic.
β Bootstrap utility classes (bg-*, text-*) help you style without custom CSS.
β Test your Kanban layout with real data to ensure readability.
β If using JavaScript, keep controllers light to maintain performance.
π Conclusion
Customising your Kanban views in Odoo 19 β with dynamic colours and click actions β enhances visual clarity and efficiency. Whether youβre managing tasks, leads, opportunities, support tickets, or projects, this approach brings contextual insight right into the board view.