Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
15160 Переглядів

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?

Аватар
Відмінити
Найкраща відповідь

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
Аватар
Відмінити
Найкраща відповідь

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"/>

Аватар
Відмінити

This is so much cleaner!! Great solution!

Найкраща відповідь
<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>
Аватар
Відмінити
Найкраща відповідь

<t if = "doc.otros_familiares_en_casa">

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

<t/>

<t if != "doc.otros_familiares_en_casa">

    <input type="checkbox">

<t/>


Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
квіт. 25
1189
2
бер. 25
1325
4
лист. 24
7047
1
бер. 24
1962
3
вер. 23
24762