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

Hi. The report gets the values from a model, and one of his fields is a boolean that returns True. The problem is that when I get this value in the report i see a string with the value "True" instead a checkbox checked.
The code I use for this field is :

¿Viven en casa otros familiares?: <span t-field="doc.otros_familiares_en_casa"/>

Can I use a checkbox instead "True" value?

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

Hello Deniel,


you can achieve this using below code:

<t t-if="doc.YOUR_BOLLEAN_FIELD">
    <input type="checkbox" id="checkbox104_anything_you_give" checked="checked"/>
</t>
below condition for print unchecked checkbox in PDF Report when condition is False
<t t-if="not doc.YOUR_BOLLEAN_FIELD">
    <input type="checkbox" id="checkbox104_anything_you_give"  />
</t>
Thanks
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Previous solution are the way Odoo Studio does it.

A better solution would be:

<input type="checkbox" t-att-checked="doc.otros_familiares_en_casa"/>

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

This is so much cleaner!! Great solution!

Câu trả lời hay nhất
<p class="form-check form-switch mb-0">
< t t-if="doc.field">
Yes:
<input type="checkbox"id="checkbox_field_true"checked="checked"/>
No:
<input type="checkbox"id="checkbox_field_false"/>
t>
<t t-if="not doc.field">
Yes:
<input type="checkbox"id="checkbox_field_true"/>
No:
<input type="checkbox"id="checkbox_field_false"checked="checked"/>
t>
p>
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

<t if = "doc.otros_familiares_en_casa">

    <input type="checkbox" checked="checked">

<t/>

<t if != "doc.otros_familiares_en_casa">

    <input type="checkbox">

<t/>


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 25
1211
2
thg 3 25
1351
4
thg 11 24
7074
1
thg 3 24
1992
3
thg 9 23
24811