This question has been flagged
2 Replies
2494 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?

Avatar
Discard
Best Answer

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
Avatar
Discard
Best Answer

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.

Avatar
Discard