跳至内容
菜单
此问题已终结
2 回复
2805 查看

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



形象
丢弃
编写者 最佳答案

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

形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
1
10月 24
2127
1
1月 19
8564
0
12月 24
1151
0
12月 24
944
2
3月 22
11784