Odoo Help


How to define a default external id in one2many field

badr elmar
on 4/25/16, 7:23 AM 1,017 views

I have 2 models with a relation one2many and many2one.

fieldmodel A = one2many model B

fieldmodel B = many2one model A

For every record B, I want to get the id of the record A (associate to B) generated by default when i open the field B

Any help please 

" generated by default" means generated form demo data ?

webkul, Prakash Sharma
on 4/25/16, 8:15 AM

It means that the id of field A appears automatically (by default) when i click on the record B

badr elmar
on 4/25/16, 8:21 AM

you can search in B using this domain 

self.pool.get(model.a).search(cr, uid, [('m2o filed ', 'in',  [currentids] )],context=context)

Krupesh Laiya
on 4/25/16, 7:56 AM

Thanks. But where i will define this domain

badr elmar
on 4/25/16, 8:38 AM

Where i have to add this domain please ??

badr elmar
on 4/25/16, 11:25 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

1 follower(s)


Asked: 4/25/16, 7:23 AM
Seen: 1017 times
Last updated: 4/25/16, 8:31 AM