Pregunta

I tried to create a simple Many2one field but the values are showing in this format: new.base,1 and new.base,2 and so on. Please let me know the fix so as to display value for the same.

class latest_base(osv.osv):
       _inherit = ['mail.thread']
       _name='latest.base'
       _columns={
                'name':fields.char('Name',required=True),

                'image': fields.binary("Image", help="Select image here"),


                'email':fields.char('Email'),
                'code':fields.many2one('new.base','code'),
               }

  latest_base()



 class new_base(osv.osv):

       _name='new.base'
       _columns={
               'code':fields.char('Department'),

               'hod':fields.char("Head of the Department"),
               }
 new_base()
¿Fue útil?

Solución

try this, name is a Special fields in OpenERP and unique name used by default for labels in forms, lists, etc. If we don't use a name in table than we use _rec_name to specify another field to use.

class latest_base(osv.osv):
   _inherit = ['mail.thread']
   _name='latest.base'
   _columns={
            'name':fields.char('Name',required=True),
            'image': fields.binary("Image", help="Select image here"),
            'email':fields.char('Email'),
            'code':fields.many2one('new.base','code'),
           }

latest_base()

class new_base(osv.osv):
   _name='new.base'
   _rec_name = 'code'
   _columns={
           'code':fields.char('Department'),
           'hod':fields.char("Head of the Department"),
           }
new_base()

Hope this will solve your problem.

Otros consejos

because you have not declared name field in your model, openerp returns name field value by default, if you want set other field as just define _rec_name='field_name' you will get value of that field.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top