Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
652 Widoki

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>
Awatar
Odrzuć
Autor

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

Najlepsza odpowiedź

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.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
4
sty 24
23218
Attrs attribute Rozwiązane
2
sty 24
2516
0
sie 23
2334
5
wrz 21
17575
3
sty 21
16860