Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
649 Переглядів

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.

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
4
січ. 24
23217
Attrs attribute Вирішено
2
січ. 24
2515
0
серп. 23
2334
5
вер. 21
17575
3
січ. 21
16856