Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
400 Vistas

OK, I know there are a lot of posts about changing colors in Kanban view, but I am soooo confused. I have a model name Horses in where I list all the horses and who owns them.


I want to create a code that based on the field x_studio_gender, it changes colors to Mare=Blue Gelding=Green and Stallion=Red.


I also need to know where to put this code. I have tried some example codes from here, and I get totally lost.


Thanks, for any help.

Avatar
Descartar
Mejor respuesta

Hello, To change Kanban card colors based on a field value in Odoo, you can achieve this by using the Kanban's QWeb templates and adding custom CSS classes dynamically based on the field value. Here's a general guideline on how to implement this feature:


Define Field: Ensure you have a field in your model that will determine the color of the Kanban card. Let's assume this field is named color_field.

Create CSS Classes: Define CSS classes for each color you want to use in your Kanban view. For example, you can have classes like kanban-color-red, kanban-color-blue, etc.

Modify Kanban Template: Override the Kanban template in Odoo to include logic that dynamically sets the appropriate CSS class based on the color_field value.

Avatar
Descartar