Odoo Help


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.


how to pass variables from one view to another?

on 4/3/14, 3:51 PM 1,232 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.


Ray Carnes

--Ray Carnes--
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

Ray Carnes
On 4/3/14, 4:13 PM


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

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

on 4/3/14, 5:07 PM
On 4/3/14, 5:12 PM

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 }

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)


Asked: 4/3/14, 3:51 PM
Seen: 1232 times
Last updated: 3/16/15, 8:10 AM