Skip to Content
मेन्यू
This question has been flagged
1 Reply
674 Views

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>
Avatar
Discard
Author

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

Best Answer

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.

Avatar
Discard
Related Posts Replies Views Activity
4
जन॰ 24
23238
2
जन॰ 24
2543
0
अग॰ 23
2348
5
सित॰ 21
17617
3
जन॰ 21
16931