We are using Odoo11 with the standard CRM addon.
Our users would like to have a (light) red background for lost opportunities and a (light) green background for won opportunities in the kanban view (model: crm.lead).
I have found that the option to color the background was replaced by a colored bar from v10 onwards. See: https://github.com/odoo/odoo/issues/34504
However, one answer to the issue contains a sample of how the background can be colored anyway.
I tried to modify this approach according to my needs but I cannot get it to work. Can someone here help, please?
I tried to add a condition that changes the background color depending on the probability: 0 means "lost" => red background, 100 means "won" => green background.
The resulting error message is all about Javascript & as I'm no pro in JS I'm clueless what it means.
My code looks like this:
<xpath expr="/kanban/templates/t/div//div[@class='oe_kanban_content']"
position="replace">
<div t-if="record.probability.raw_value == 0" style="background-color: #00FF00;">
<div class="oe_kanban_content">
...
... (I inserted code from the original view here - not good practice, I know)
...
</div>
</div>
</xpath>
Hello Chris, thank you for your answer. This took me on step further (kind of) but it didn't solve my problem.
One step further because the code works & does indead change the color of the kanban items - but instead of the background it only changes the thin bar on the left side.
The field x_studio_vip_color is nothing 'special' coming from JS - it's just a field you added on your own, right?
One question: The original code uses class="oe_kanban_content" and not class="o_kanban_card_content". Does that make a (big) difference?
Sorry, this is an example that I managed to get working in a test database without fully understanding all the details. The concept is that there are VIP customers so the Kanban card changes color. That field was added to the customer.
On my system it changes the background color of the card. What version of Odoo are you using?
<p>
We are using Odoo11.
<br/></p>