تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
2911 أدوات العرض

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
أكتوبر 24
2280
1
يناير 19
8639
0
ديسمبر 24
1206
0
ديسمبر 24
1005
2
مارس 22
11882