Odoo Help


Show a field from inside a many2one relation [Closed]

aaa aaa
on 11/14/13, 12:17 PM 4,593 views

The Question has been closed

Serpent Consulting Services Pvt. Ltd.
on 11/15/2013 06:54:53

In model stock.move we have prodlot_id that has a many2one relation to stock.production.lot. Then we have the table stock.move.tree that has a field

< field name="prodlot_id"> groups="stock.group_production_lot"/>

But it actually shows the name from inside stock.production.lot.Where does this mapping happen? what if I want to show stock_available from inside stock.production.lot as a field? How can I do that?

field name="prodlot_id.stock_available" does not work


Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 11/15/13, 1:26 AM

Hello Eikos Quinn,

This all thing works on field name.

Thing is that many2one field shows the value of name field. In your case prodlot_id is a many2one of stock.production.lot object and it shows the value of name field.

It is recommended that your object should have name field. If you don't want to put name field then you should use any field for _rec_name.

_rec_name: Name of the field in which the name of every resource is stored. Default value: 'name'. Note: by default, the name_get method simply returns the content of this field.

For _rec_name refer: Link m2o field to a specific field in another class.

Now, as per your requirement/question there are two options.

1: You inherit 'stock.production.lot' and give stock_available in _rec_name.

2: I would suggest you to create a related field of stock_available of object 'stock.production.lot' in stock.move.


'stock_available': fields.related('prodlot_id', 'stock_available', string='Stock Available')

Hope this will help you.


Serpent Consulting Services

Thank you, I really did not know about _rec_name.I have used a related field as you suggested and it worked fine!Kind regards, Eikos Quinn

aaa aaa
on 11/15/13, 6:05 AM

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: 11/14/13, 12:17 PM
Seen: 4593 times
Last updated: 3/16/15, 8:10 AM