0
votes

I have to show the records of a custom module in a tree view (not list)

<field name="view_type">tree</field>

Instead of

<field name="view_type">form</field>

However, I would also like to be able to go to the records' corresponding forms when I click on them. Based on what I read, it's not possible, at least not by default. Is there any workaround to 'fix' it?

Here is my code:

<!-- Estrutura de Redes -->
        <record id="edit_estrutura" model="ir.ui.view">
            <field name="name">gestao.rede.estrutura.form</field>
            <field name="model">gestao.rede.estrutura</field>
            <field name="arch" type="xml">
                <form string="Estrutura da Rede">
                    <header>
                        <!--<button name="" string="Desabilitar" type="object" states="habilitado"/>-->
                        <!--<button name="" string="Habilitar" type="object" states="desabilitado"/>-->
                    </header>
                    <sheet string="Estrutura da Rede">
                        <div class="oe_nome">
                            <label for="razao_social" class="oe_edit_only" string="Nome"/>
                            <h1>
                                <field name="name" string="Nome:"/>
                            </h1>
                            <label string="Pasta Acima:"/>
                            <field name="parent_id" options="{'no_create': True}"/>
                            <label string="Variável:"/>
                            <field name="variavel"/>
                            <label string="Pastas Abaixo:" class="oe_read_only"/>
                            <field name="pastas_filho" options="{'no_create': True}" class="oe_read_only"/>
                        </div>
                    </sheet>
                </form>
            </field>
        </record>

    <record id="view_estrutura_tree" model="ir.ui.view">
        <field name="name">gestao.rede.estrutura.tree</field>
        <field name="model">gestao.rede.estrutura</field>
        <field name="field_parent">pastas_filho</field>
        <field name="arch" type="xml">
            <tree string="Estrutura da Rede" delete="true" editable="bottom/top" toolbar="1">
                <field name="name"/>
                <field name="pastas_filho"/>
                <field name="parent_id"/>
                <field name="variavel"/>
            </tree>
        </field>
    </record>

    <record id="open_view_gestao_estrutura_all" model="ir.actions.act_window">
        <field name="name">Estrutura da Rede</field>
        <field name="res_model">gestao.rede.estrutura</field>
        <field name="view_type">tree</field>
        <field name="domain">[]</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="view_estrutura_tree"/>
    </record>
    <menuitem action="open_view_gestao_estrutura_all"        id="menu_action_estrutura"        parent="menu_gestao_redes" sequence="20"/>

Thanks!

2

2 Answers

0
votes

Editable Tree View

by default, selecting a list view's row opens the corresponding form view. The editable attributes makes the list view itself editable in-place.

Valid values are top and bottom, making new records appear respectively at the top or bottom of the list.

The architecture for the inline form view is derived from the list view. Most attributes valid on a form view's fields and buttons are thus accepted by list views although they may not have any meaning if the list view is non-editable

Example:

<tree editable="bottom/top"> 
   <field name="xyz"/>
</tree>
0
votes

Try this

 <tree editable="bottom"> 
      Add your fields
  </tree>