Skip to Content
Menu
This question has been flagged
2 Replies
2286 Rodiniai

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



Portretas
Atmesti
Autorius Best Answer

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

Portretas
Atmesti
Best Answer

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

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
1
spal. 24
1621
1
saus. 19
8228
0
gruod. 24
826
0
gruod. 24
716
2
kov. 22
11488