コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
650 ビュー

In Odoo version 17, can I insert views (model="ir.ui.view") inside view depending on a field of the model of the main view? Like this one:

<odoo>
    <data>
        <record model="ir.ui.view" id="shipment_form_view">
            <field name="name">shipment.form.view</field>
            <field name="model">shipment</field>
            <field name="arch" type="xml">
               <form>
                  <field name="transport" />
                  <!--
                  If transport == air, use air.shipment.form.view
                  If transport == ocean, use ocean.shipment.form.view
                  -->
        </record>

        <record model="ir.ui.view" id="air_shipment_form_view">
            <field name="name">air.shipment.form.view</field>
            <field name="model">shipment</field>
                <form>
                    <field name="name"/>
                    <field name="flight_no"/>
               ...
        </record>

        <record model="ir.ui.view" id="ocean_shipment_form_view">
            <field name="name">ocean.shipment.form.view</field>
            <field name="model">shipment</field>
                <form>
                    <field name="name"/>
                    <field name="voyage_no"/>
               ...
        </record>
         ...

I tried using the using the owl directive but it displayed an error, that it is illegal

<t t-if>
アバター
破棄
著作者

Thanks, I do not have karma to check or upvote your comments.

最善の回答

No. 

What you do instead is make View elements invisible.


Take a look at how we do this on the Product Form View, depending on the Product Type:

You can make Notebook Pages invisible (even giving them the same name) to give the appearance that they are changing based on the field, when really one is becoming invisible and the other visible.

アバター
破棄
関連投稿 返信 ビュー 活動
4
1月 24
23217
2
1月 24
2515
0
8月 23
2334
5
9月 21
17575
3
1月 21
16856