Skip to Content
Menu
This question has been flagged
2 Replies
12071 Views

lets say we have a module A which has a one2many field to module B and a company field. after choosing company in the form view from module A we click on "Add an Item" to add an item to the one2many field, which opens the view form from module B.

how can I e.g. automatically set the company in module B to the same which was selected in view from module A?

thank you.

Avatar
Discard
Best Answer

context

You probably want something like context="{'company_id':company_id}" and this would go on the field that represents the one2many relationship

See also https://accounts.openerp.com/forum/Help-1/question/8598

Avatar
Discard
Author

_defaults = { 'a_field' : lambda self, cr, uid, context : context['a_field'] if context and 'a_field' in context else None }

Author Best Answer

thanks, another thing we need is the following:

_defaults = { 'a_field' : lambda self, cr, uid, context : context['a_field'] if context and 'a_field' in context else None }

Avatar
Discard
Related Posts Replies Views Activity
1
May 19
2636
5
Aug 24
42979
2
Apr 24
949
3
Jun 23
3137
2
Jun 23
2377