Odoo Help

Welcome!

This community 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.

1

Problem with many2one field data [Closed]

By
ghofrane
on 5/14/13, 2:11 PM 1,374 views

The Question has been closed

by
Sudhir Arya (SA)
on 05/15/2013 08:12:38

Hi,

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'
_columns{

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

class a(osv.osv):

_name : 'a_a'
_columns{

'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

gpkarthick
on 5/15/13, 7:00 AM
1

Brett Lehrer

--Brett Lehrer--
1252
| 5 4 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
0
ghofrane
On 5/15/13, 6:19 AM

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

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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