I want to add a select list to the Product Template view which shows values from my new, supplemental table. I found this function in the documentation:
Using relation fields many2one with selection. In fields definitions add:
..., 'my_field': fields.many2one( 'mymodule.relation.model', 'Title', selection=_sel_func), ...,
And then define the _sel_func like this (but before the fields definitions):
def _sel_func(self, cr, uid, context=None):
obj = self.pool.get('mymodule.relation.model')
ids = obj.search(cr, uid, [])
res = obj.read(cr, uid, ids, ['name', 'id'], context)
res = [(r['id'], r['name']) for r in res]
return res
This works, and I correctly get the name field in the selection list, and the database stores the record id. However, I would like to tweak this function a bit, so that I get a concatenation of 'name' and 'description' in my selection list. I have tried various options, but my selection list always renders exactly the same as before. I know very little Python. How would I modify the above function to get '[name] description' as the displayed option in my select list?