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).
you can use this code for your requirement:
<record model="ir.ui.view" id="base_view_partner_tree_inherit">
<field name="inherit_id" ref="base.view_partner_tree" />
<field name="arch" type="xml">
<xpath expr="//tree[@string='Contacts']/field[@name='email']" position="attributes">
<xpath expr="//tree[@string='Contacts']/field[@name='phone']" position="attributes">
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"> <tree> <field name="name" /> </tree> </field>
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 4/1/15, 9:19 AM|
|Seen: 1044 times|
|Last updated: 4/10/15, 2:34 AM|