Use name_get in odoo 9

筅森魡賤 提交于 2020-03-06 04:18:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!