Odoo Help


How to do pre data population on a one2many field?

Anirudh Lou
on 2/10/15, 5:45 AM 1,209 views

Hi to all, does any one knows how to prepopulate a data on a one2many field? I mean, when a user clicks "Add an item" on a one2many fields some fields from this line will populated? I have here the image.


Any help is much appreciated.




| 5 3 6
Jakarta, Indonesia
On 2/10/15, 6:00 AM

The image is not shown.  Anyway, it is a combination of _defaults value (and overriding the default_get method of ORM) and on_change on the fields that are given _defaults.


Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
| 5 5 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 2/10/15, 6:01 AM

You could use context to set the values of the fields at one2many field
In res.partner table, odoo uses context to pass the values of Company to its Contacts.  Refer:https://github.com/odoo/odoo/blob/8.0/openerp/addons/base/res/res_partner_view.xml#L191


(*) default_FIELDNAME ==> set value for your particular field
(*) search_default_FILTERNAME ==> sets the search filter by default

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

1 follower(s)


Asked: 2/10/15, 5:45 AM
Seen: 1209 times
Last updated: 3/16/15, 8:10 AM