Search code examples
odooodoo-10odoo-9

Use name_get in odoo 9


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):

???

Solution

  • 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.