Odoo Help


Odoo v8 show first and last name in drop-down list

Daniel Holden
on 2/1/16, 11:01 AM 789 views

I have Openeducat ERP installed in Odoo 8 on a Windows 2008 R2 server.

Students in Operneducat have three fields for their names: Name, Middle Name and Last Name

When I want to issue and invoice for a student, in the Customer field I only see the value for the "Name" field. I would like to change the view to show both "Name" and "Last Name" as a concatenated string in the drop-down list.

How can I achieve this?

On 2/3/16, 9:40 AM

You can achieve this by overriding name_get() method of odoo.

For Example:

This is Odoo 8 method.

def name_get(self):
    res = []
    for value in self:
        res.append([value.id, "%s %s %s" % (value.name, value.middle_name, value.last_name)])
    return res
Cyrus Waithaka
On 2/1/16, 12:10 PM

In odoo version 8, the display name is by default the value of the 'name' field or the value of the field specified by _rec_name. To customize this, you need to override the name_get method in the op.student model as follows:

class op_student(osv.osv):

_inherit = 'op.student'    def name_get(self, cr, uid, ids, context=None):

if not len(ids):
return []
res = [(r['id'], r['name'] and '%s %s' % (r['name'], r['last_name']) or r['name'] ) for r in self.read(cr, uid, ids, ['name', 'last_name'], context=context) ]
return res

You will obviously need to create a custom module to achieve this. I hope that helps.

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/1/16, 11:01 AM
Seen: 789 times
Last updated: 2/3/16, 9:40 AM