Odoo Help

Welcome!

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.

0

Custom view for res.partner

By
Balvant
on 3/24/15, 3:46 AM 757 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 ?

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

You should read this document once.

https://www.odoo.com/files/memento/OpenERP_Technical_Memento_latest.pdf

0
Balvant
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.

0
SonnyV
On 3/24/15, 6:23 AM

Hello

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"/>
                    </form>
            </field>
</record>

<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">
                    <tree>
                         <field name="field1"/>
                         <field name="field2"/>
                    </tree>
            </field>
</record>

<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>
</record>

<!-- 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)

Stats

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