There are some related questions online, but I haven't found a working answer yet, so here I go.
I have a custom module that adds a field to the crm.lead:
xx_ue_brand_id = fields.Many2one('xx.ue.brand', string='Brand')
The related model holds not much more than a name and and active flag. I'm using this already in the crm related views, so user can link a Lead to a specific brand.
Using the brand value, I would like to set a color on the kanban items. As each brand has its specific color, I would prefer not to use the standard Odoo colors for the kanban-item, which can be set by the color picker and add a class like 'oe_kanban_color_5'
I defined my own css classes in a less file that is correctly loaded. There's a class for each brand, overruling the border color that is set on the kanban. I included the brand name in the class definition, so it's clear for which brand the styling is used. Like this:
.crm_kanban_brand_*brandname-x* { &:after {background-color:#2E3092!important;} }
When I add this class via the developer tools of Chrome to a kanban item, the border is set in the right color.
But... (finally my question)
I can't get the classes set dynamically through an xpath expression, my best guess is something like the following.
<xpath expr="//div[hasclass('o_dropdown_kanban')]/parent::div" position="attributes">
<attribute name="t-att-class">'crm_kanban_brand_%s' % record.xx_ue_brand_id.name</attribute>
</xpath>
Note, when I add the class definition without using a variable, the whole thing works as expected, adding the same class to all kanban items.
<xpath expr="//div[hasclass('o_dropdown_kanban')]/parent::div" position="attributes">
<attribute name="class">crm_kanban_brand_*brandname-x*</attribute>
</xpath>
Any help on how I could use the field value as part of the class name would be greatly appreciated.
t-attf-class
? Something like<attribute name="t-attf-class">crm_kanban_brand_{{record.xx_ue_brand_id.name}}</attribute>
might work. – CZoellner