Here is some information on Odoo – How to overide ORM Method: name_get
In HR module of Odoo, when we open Employee form view, we can see there is only one field available in order to enter Employee Name. If we enter employee name over here, it can be used anywhere across different modules where a reference is made to it as a many2one field of hr.employee class. Generally name field of a class appears in many2one reference of that class in another classes. So whatever name we enter in name field in Employee Form, it will get displayed in many2one reference.
In one of our project we had to put three different fields namely first name, middle name and last name(first name was required field) and apart from that it was also required that the combination of provided inputs needs to be shown in many2one reference. So in this case,we had to override the existing name_get method in hr.employee class as follow.
def name_get(self,cr,uid,ids,context=None): res =  if not ids: return res if isinstance(ids, list): services = self.read(cr, uid, ids, ['name','middle_name','last_name'], context=context) for service in services: fn = service['name'] mn = service['middle_name'] ln = service['last_name'] if fn and not mn and not ln: cid = fn elif fn and mn and ln: cid = fn+" "+mn+" "+ln elif fn and mn and not ln: cid = fn+" "+mn elif fn and ln and not mn: cid = fn+" "+ln else: cid = "" res.append((service['id'], cid)) return res else: return res or ids
|Here is another module where it shows separate fields for First Name, Middle Name and Last Name.||Here it shows the combined fields|