Hi Alejandro,
Here is the function I used recently to retrieve a combination of two fields as the name:
@api.multi
def name_get(self):
retvals = []
for record in self:
if self.env.context.get('prod_form', False):
catstring = "[" + record.name + "] " + record.description
retvals.append((record.id,catstring))
else:
retvals.append((record.id,record.name))
return retvals
In this case, it returns the combination of 'name' and 'description' only when the 'prod_form' context is true. It should steer you in the right direction, though, as it uses the new v8 API form. Notice that the function only needs 'self' as a parameter. All the other variables (cr, uid, ids, context, etc.) are wrapped up in the environment, which is part of 'self'.
In this post, Marvin helped me understand what (I hope) I explained above. My original question also contains a link to the API documentation, if you haven't found that already.
I think you also want to declare your field like this:
name = fields.Char(compute='yourFunction_name')
The problem here is I wasn't iterating on the element (which should be elements). A res list should also be declared as empty and append the custom name to this list with the record id.