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

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

By
Daniel Holden
on 2/1/16, 11:01 AM 410 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?

1
Jinesh
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.

@api.multi
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
0
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.

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