Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
13516 Lượt xem

I have the following code in the XML which denotes the kanban view for the res_partner model:-

<record model="ir.ui.view" id="partner_kanban_view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.res_partner_kanban_view"/>
<field name="arch" type="xml">
<field name="mobile" position="after">
<field name="starmark_name"/>
</field>
<xpath expr="//div[hasclass('oe_kanban_partner_links')]" position="inside">
<span t-if="record.starmark_name!=''" title="Starmark Color" class="badge">
<i class="fa fa-fw fa-bullhorn"/>
<t t-esc="record.starmark_name.value"/>
</span>
</xpath>
</field>
</record>

This looks like this - https://i.ibb.co/B64ymDx/Screenshot-from-2020-01-11-12-49-42.png

Here the starmark color field has to be simultaneously highlighted. I am able to hardcode the color in the xml like below and get it to look like this - https://i.ibb.co/0FYt4R9/image.png

<span t-if="record.starmark_name!=''" title="Starmark Color" class="badge" style="background: yellow;">
    <i class="fa fa-fw fa-bullhorn"/>
    <t t-esc="record.starmark_name.value"/>
</span>

Now the question is - how do I programmatically do this so that I can pull the color from the model and automatically color each of the kanban tiles with the appropriate color for that record?


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

t-attf-style="background-color: #{record.color_field.value};"

Ảnh đại diện
Huỷ bỏ

Is this supposed to work on Odoo 11?

Câu trả lời hay nhất

in odoo17 it's commonly used in templates . 
code like this 


t-attf-style="color: #{tag.color}"
t-field="tag.name"


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

use .raw_value

t-attf-style="background-color: {{record.color_field.raw_value}};"

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất


this is not working in the odoo 16 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 12 24
2339
1
thg 7 24
1897
1
thg 7 24
1909
1
thg 6 24
2479
1
thg 4 23
10424