How to change the order of forms and tree views in Odoo?

I created a module with normal settings, which shows the form view and tree view. The default behavior is to first show the form view. I need to change this and show the tree view as the default view.

I tried to use the sequence attribute and changed the values ​​with different values, but this did not solve the problem.

<field name="sequence" >1</field> 

In addition, I tried to reorder the view_mode attribute:

 <field name="view_mode" >tree,form</field> 
+5
source share
1 answer

First we need to reorder ir.actions.act_window and below

Demo version for client (partner)

 <record id="base.action_partner_form" model="ir.actions.act_window"> <field name="name">Customers</field> <field name="type">ir.actions.act_window</field> <field name="res_model">res.partner</field> <field name="view_type">form</field> <field name="view_mode">tree,form,kanban</field> <field name="domain">[('customer','=',1)]</field> <field name="context">{'default_customer':1, 'search_default_customer':1}</field> <field name="search_view_id" ref="base.view_res_partner_filter"/> <field name="filter" eval="True"/> <field name="help" type="html"> <p class="oe_view_nocontent_create"> Click to add a contact in your address book. </p><p> OpenERP helps you easily track all activities related to a customer: discussions, history of business opportunities, documents, etc. </p> </field> </record> 

Also change the sequence to look something like this

 <record id="base.action_partner_tree_view1" model="ir.actions.act_window.view"> <field name="sequence" eval="0"/> <field name="view_mode">tree</field> <field name="view_id" ref="base.view_partner_tree"/> <field name="act_window_id" ref="base.action_partner_form"/> </record> <record id="base.action_partner_form_view2" model="ir.actions.act_window.view"> <field eval="1" name="sequence"/> <field name="view_mode">form</field> <field name="view_id" ref="base.view_partner_form"/> <field name="act_window_id" ref="base.action_partner_form"/> </record> <record id="base.action_partner_form_view1" model="ir.actions.act_window.view"> <field eval="2" name="sequence"/> <field name="view_mode">kanban</field> <field name="view_id" ref="base.res_partner_kanban_view"/> <field name="act_window_id" ref="base.action_partner_form"/> </record> 

The code works well on my side.

I hope this will be useful for you .. :)

+7
source

Source: https://habr.com/ru/post/1213862/


All Articles