Odoo Help


This community 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.


Custom view for res.partner

on 3/24/15, 3:46 AM 696 views

I want to create new form view and tree view for res.partner with only 2-3 fields. Also i want res.partner form and tree view as it is.

I want to create new menu and puts new created view under that. How to possible ?

Michael Pol
On 3/24/15, 4:31 AM

You should read this document once.


On 3/25/15, 1:17 AM

Hello Sonny

I already tried this whatever you written here. it open default form/tree view (original) of res.partner. I want only some fields in my views.

On 3/24/15, 6:23 AM


Not sure if I understand your question properly, but I guess you'd like to create a new form and tree for res.partner under a new menu.

To achieve this you create a new record in xml, from the model res.partner (not inheriting, since it will not use anything from the res,partner)

The next thing to do is create a python class that inherits from res.partner and create the needed fields here.

in xml:

<record model="ir.ui.view" id="view_partner_form_custom">
            <field name="name">view.partner.form.custom</field>
            <field name="model">res.partner</field>
            <field name="arch" type="xml">
                    <form string="New Form">
                         <field name="field1"/>
                         <field name="field2"/>

<record model="ir.ui.view" id="view_partner_tree_custom">
            <field name="name">view.partner.tree.custom</field>
            <field name="model">res.partner</field>
            <field name="arch" type="xml">
                         <field name="field1"/>
                         <field name="field2"/>

<record model="ir.actions.act_window" id="custom_partner_action">
            <field name="name">Custom Partner</field>
            <field name="res_model">res.partner</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>

<!-- top level menu: no parent -->

<menuitem id="custom_partner_menu" name="Custom Partner" action="custom_partner_action"/>


in python:

class custom_partner(models.Model):
    _inherit = 'res.partner'
    field1 = fields.Char()
    field2 = fields.Char()

This should get you some a new menuitem, when you click this item, the formview opens. Might need a tweak here and there. Since I did not test this code.

Your Answer

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

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 3/24/15, 3:46 AM
Seen: 696 times
Last updated: 3/25/15, 1:17 AM