Community mailing list archives

Re: Many2One in Odoo v9 community

GH Mediacloud, Grover Menacho
- 10/06/2016 10:01:08

You need to set your _rec_name, choose a column to act as name if you don't have that field on the comodel.

_name = 'comodel.object'

_rec_name = 'column_name'

Other option to create complex names is name_get

def name_get(self)

Grover Menacho Q.
GH Mediacloud

De: Kristian Koci <>
Enviado: jueves, 06 de octubre de 2016 09:58 a.m.
Para: Community
Asunto: Many2One in Odoo v9 community

Hi, I'm on Odoo v9 community

I just want to know how to show a Char field as a Many2one in v9, since it has changed a little.

So, I have this model:

class mymodel(models.Model):
    _name = 'mymodel'

    field_ = fields.Char(string="This is a field")

And then I load this into, let's say account.invoice model:

class account_invoice(models.Model):
    _inherit = "account.invoice"

    relation = fields.Many2one(comodel_name="mymodel", string="That other field")

If I do this, the relation is there, and it shows the field, BUT; it is not showing the actual content of the field, just and id like: mymodel,1

How can I fix this to actually show the Char field content?

Thanks in advance!
Kristian Koci
Linux User #582221
Public repository:
kkoci has 60 repositories available. Follow their code on GitHub.

Post to: