Skip to Content
Menu
This question has been flagged
2 Replies
4866 Views

Here below is the code.On saving the form it saves, But when i clicked on the tree view the form which i created was not there..it not showing any thing..Why it is not fetching from database??


<record model="ir.ui.view" id="demo_view_tree_view">

    <field name="name">demo.view.tree</field>

    <field name="model">demo.view</field>

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

    <field name="arch" type="xml">

        <tree string=" View" >

            <field name="project_name"/>

            <field name="code"/>

         </tree>

    </field>

</record>

<record model="ir.ui.view" id="demo_view_form_view">

        <field name="name">demo.view.form</field>

        <field name="model">demo.view</field>

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

        <field name="arch" type="xml">

        <form string="Sample">

            <sheet>

            <group>

                <field name="project_name" />

                    <field name="code"/>

               </group>

            </sheet>

        </form>

    </field>

</record>

<record model="ir.actions.act_window" id="action_demo_view_bam">

        <field name="name">Projects</field>

        <field name="type">ir.actions.act_window</field>

        <field name="res_model">demo.view</field>

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

        <field name="view_id" ref="demo_view_tree_view"/>

        <field name="help" type="html">

        <p class="oe_view_nocontent_create">

        Click to enter .

        </p><p>

        Use this menu to enter the details .

        </p>

        </field>

</record>

Avatar
Discard
Author

I have tried this too . and also created a Create function for this model.then also tree view showing nothing and when i tried to access the database it showing some kind of access errors and all

Best Answer

When you want to show a model in mutiple view_mode : like tree,form,kanban  use this to specify the view_ids for the action because when you have multiple tree views for the model odoo choses the default one :


<record id="dgapr_action_id" model="ir.actions.act_window">

<field name="name">Projects</field>

<field name="res_model">demo.view</field>

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

<field name="view_mode">tree,form</field>

<field name="view_ids"

eval="[(5, 0, 0),

(0, 0, {'view_mode': 'tree', 'view_id': ref('demo_view_tree_view')}),

(0, 0, {'view_mode': 'form'}),

]"

/>

<field name="help" type="html">

<p class="oe_view_nocontent_create"> Click to enter . </p><p> Use this menu to enter the details .</p>

</field>

</record>

Avatar
Discard
Author

I have tried this too . and also created a Create function for this model.then also tree view showing nothing and when i tried to access the database it showing some kind of access errors and all

Best Answer

In the defined of action, you have to define the tree mode into view_mode as bellow


<field name="view_mode">tree,form</field>


hope it helps

Avatar
Discard