Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
2230 Vistas

I want to pass multiple variable to template. In odoo documentation, when we call a template and want to show the data, it uses t-out="0". that is just a variable. what if I want to pass multiple variable? is it possible?




    <template id="watermark_report_tmpl">
        <t t-if="state == 'draft'">
            <div class="watermark-parent">
                <div class="watermark">
                    <t t-foreach="range(30)" t-as="index">
                        <p t-out="state"/>
                        <p t-out="another_message"/>
                    </t>
                </div>
            </div>
        </t>
    </template>

    <t t-call="watermark_report_tmpl">
       
    </t>


I'm using odoo 16



Avatar
Descartar
Autor Mejor respuesta

https://www.odoo.com/documentation/16.0/developer/reference/frontend/qweb.html#calling-sub-templates


In that documentation explained that if we put

<t t-call="other-template">
    <t t-set="var" t-value="1"/>
</t>
<!-- "var" does not exist here -->

We can use var​ inside the other-template​. This is how odoo pass argument to other template

you can pass multiple value in it. for example

<t t-set="outside_var" t-value="5"/>
<t t-call="other-template">
    <t t-set="var" t-value="1"/>
    <t t-set="var2" t-value="2"/>
    <t t-set="var3" t-value="outside_var"/>
</t>
<!-- "var" does not exist here -->


var, var2, var3 will be available in other-template

Avatar
Descartar
Mejor respuesta

using t-att-data you can pass multiple data from it

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
oct 24
1563
1
ene 19
8187
0
dic 24
772
0
dic 24
680
2
mar 22
11441