Odoo Help


using name_get how to shows two different display values?

on 2/21/13, 12:56 AM 9,125 views

I have two fields related with res.partner.addreess

_name = "contact_details"
_columns = {
        'contact_id': fields.many2one('res.partner.address', 'Contact Name'),
        'contact_address_id': fields.many2one('res.partner.address', 'Contact Address'),

In the contact_details Form:-

Currently display

Contact Name --> Contact Name with address

Contact Address --> Contact Name with address

Actual Requirement

Contact Name --> Contact Name only

Contact Address --> Contact Name with address

Using name_get Is it possible using name_get to show contact Name and Contact Address in Field 1 and field 2 ???



Fabien Pinckaers (fp)

--Fabien Pinckaers (fp)--
| 6 8 8
fsdsdfsdf, Belgium
--Fabien Pinckaers (fp)--

Odoo Founder & CEO

Fabien Pinckaers (fp)
On 3/2/13, 9:15 AM

Yes, you must put a context on one of the two fields (in the view or in the field) and develop a name_get on thre res.partner object that returns different values according to the context.

OpenERP has already such an implementation for partners. This should work in your view, for v7:

<field name="contact_id"/>
<field name="contact_address_id" context="{'show_address': 1}" options='{"always_reload": True}'/>

Hi Fabien Pinckaers , I have doubt regards passing context value in XML file . Can you please explain with example .

on 6/5/13, 1:45 PM
Abegail Sanchez
On 7/15/14, 2:04 AM

Hi Fabien,

this helped me, thanks

this was he meant

def name_get(self,cr,uid,ids,context=None):
        if context is None:
            context ={}
        for object in record_name:

                if object.name
                   if context.get('show_address',False):
                          //name for contact_address_id field

                       //name for contact_id field                     

        return res

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: 2/21/13, 12:56 AM
Seen: 9125 times
Last updated: 3/16/15, 8:10 AM