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.

0

Show a field from inside a many2one relation [Closed]

By
aaa aaa
on 11/14/13, 12:17 PM 3,555 views

The Question has been closed

by
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

2

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 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.

Ex:

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

Hope this will help you.

Thanks,

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 11/14/13, 12:17 PM
Seen: 3555 times
Last updated: 3/16/15, 8:10 AM