Odoo Help


Override tree view for a Many2one field

Dewilde Valentin
on 4/1/15, 9:19 AM 2,560 views

I'm building a module and i wanted to know how we can override the default tree view for a Many2one field just for this module.

In fact, i'm planning to use the model 'res.partner' and i want that the tree view display only the name and not the email and tel. for my Many2one field (it's for store authors for a book and i don't want to display email and tel for editing this field).




| 5 3 8
Pondicherry, India
On 4/1/15, 9:37 AM

hi Dewilde,

you can use this code for your requirement:

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

<field name="name">res.partner.tree.inherit</field>

<field name="model">res.partner</field>

<field name="inherit_id" ref="base.view_partner_tree" />

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

<xpath expr="//tree[@string='Contacts']/field[@name='email']" position="attributes">

<attribute name="invisible">1</attribute>


<xpath expr="//tree[@string='Contacts']/field[@name='phone']" position="attributes">

<attribute name="invisible">1</attribute>




Thanks a lot, it work.

Dewilde Valentin
on 4/1/15, 9:56 AM

I didn't see that the first time but your solution disable the display of email and tel for all module. Is there a way to hide the email and tel just for one module (he one i create) and conserve for all other modules ?

Dewilde Valentin
on 4/1/15, 10:03 AM
Dewilde Valentin
On 4/10/15, 2:34 AM

I finally found a way to overide a view for a Many2one, Many2many field just for one module and save the same display for other module (exemple, I want my Many2many field reference with res.partner to display only the name but save the name, tel., email display for my other modules).

To complete this task we can extend the Many2many field and overide the view inside the field like this :

<field name="author_ids">
	<field name="name" />

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/1/15, 9:19 AM
Seen: 2560 times
Last updated: 4/10/15, 2:34 AM