Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Problem with many2one field data [Closed]
The Question has been closedby
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,
_name : 'b_b'
_rec_name : 'product_id'
'product_id' : field.many2one('product.product', ...), ......
_name : 'a_a'
'custom_field' : field.many2one('b_b', ...), ......
in xml file :
but here i see just number! and i can't see the "label" fields of b_b class !!
i need Help please!!
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.
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 5/14/13, 2:11 PM|
|Seen: 1692 times|
|Last updated: 3/16/15, 8:10 AM|