Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
2291 Tampilan

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
Buang
Penulis Jawaban Terbai

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
Buang
Jawaban Terbai

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

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Okt 24
1622
1
Jan 19
8231
0
Des 24
837
0
Des 24
719
2
Mar 22
11496