You can use 'name_get' method to achieve this.
def name_get(self,cr,uid,ids,context=None):
result = {}
for record in self.browse(cr,uid,ids,context=context):
result[record.id] = record.name + " " + record.lastname
return result.items()
Following is just an example:
There is a model 'sale.order', in that there is a model 'res.partner' as many2one. So let's say you want to display 'First Name' and 'Last Name' of that partner in that many2one field.
So for that you have to write your code in the model 'res.partner', not in the 'sale.order' model.
Here is the code in 'res.partner' model.
class res_partner_extention(osv.osv):
_inherit = 'res.partner'
def name_get(self,cr,uid,ids,context=None):
result = {}
for partner in self.browse(cr,uid,ids,context=context):
result[partner.id] = partner.name + " " + partner.lastname
return result.items()
So now, in the 'sale.order' when you will try to look into the partner field, when you click on that many2one partner field it will show you 'First Name' as well 'Last Name'. So you don't need to anything 'sale.order' model nor you have to define any field as 'field.function'.