问题
How to concatenate Many2one field, open drop down list all car is visible. I need [id] and [name].
For example:
[01] Audi,
[02] BMW
car_id = fields.Many2one('my.cars', 'Cars')
@api.multi
def name_get(self):
???
回答1:
Try with following:
@api.multi
def name_get(self):
result = []
for record in self:
name = '[' + str(record.id) + ']' + ' ' + record.name
result.append((record.id, name))
return result
Note:
name_get() method must be set on my.cars object.
来源:https://stackoverflow.com/questions/42441851/use-name-get-in-odoo-9