Odoo Help


Problem with many2one field data [Closed]

on 5/14/13, 2:11 PM 1,796 views

The Question has been closed

Sudhir Arya (ERP Harbor Consulting Services)
on 05/15/2013 08:12:38


Please i need your help, I am a beginner in openerp, i use opeenrp v7, and i create my first model, i have class "a" which contain many2one field and another class "b" which also contain a many2one field,

class b(osv.osv):

_name : 'b_b'
_rec_name : 'product_id'

'product_id' : field.many2one('product.product', ...), ......

class a(osv.osv):

_name : 'a_a'

'custom_field' : field.many2one('b_b', ...), ......
} a()

in xml file :

<field name="custom_field"/>

but here i see just number! and i can't see the "label" fields of b_b class !!

i need Help please!!

give this inside <group><field name="custom_field"/></group> it's really works

on 5/15/13, 7:00 AM

Brett Lehrer

--Brett Lehrer--

| 5 5 8
Milwaukee, United States
--Brett Lehrer--
Director of IT and open source enthusiast.
Brett Lehrer
On 5/14/13, 2:22 PM

Small detail: Generally speaking, you should use dots instead of underscores for your _name. Doesn't really matter, just a common practice. 'b.b' rather than 'b_b'.

A many2one field literally is just an id. So setting that as a _rec_name won't work, you'll need to use a related field to pull the name from the many2one field in b_b, then set that related field as _rec_name:

'name': fields.related('product_id', 'name', type='char', size=128, string='Product Name'),

Since this field is being called 'name', _rec_name doesn't need to be set. If you wanted to use another field name, then just set it as whatever you call that related field.

Hi, if you use attribute type char, you should use attribute size too .... bye

Cyril Gaspard (GEM)
on 5/14/13, 6:10 PM
On 5/15/13, 6:19 AM

Thank you for your answers, it work now :)))

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 5/14/13, 2:11 PM
Seen: 1796 times
Last updated: 3/16/15, 8:10 AM