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.


Can I get context's variables e.g active_id in on_change wizard function

Ahmed M.Elmubarak
on 1/5/15, 2:09 PM 1,609 views


I have on_change function in a wizard ... I'm trying to get the context variable such as 'active_id' or pass new variables from the xml, but it always shows me empty context .

is there any way to get active_id of the parent form in my on_change method ..

thanks ...

active_id is passed when a wizard is called from a button or short cut Menu. How are you calling your wizard?

on 1/6/15, 4:14 AM

post your code here, to get better idea

Emipro Technologies Pvt. Ltd.
on 1/6/15, 4:56 AM
On 1/6/15, 5:44 AM

Hello Ahmed M.Elmubarak,

Usually, if you want to access the current value of context, you have to add the variable : context, in your xml view, for example : 

<field name"=your_field" on_change="your_onchange_method(field1, field2, context)"/>

Assuming that field1 and field2 are present in your model AND in your current view (as it supplies the current value of those fields, eventually modified by the user, not their actual stored value in db). 

Finally, your method may have the following signature to be usable: 

def your_onchange_method(self, cr, uid, ids, field1, field2, context): 

    # ids has no value, but has to be present


Hope it helps you,


Thanks mate , yes this passed the context ...

Ahmed M.Elmubarak
on 1/6/15, 6:08 AM

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

4 follower(s)


Asked: 1/5/15, 2:09 PM
Seen: 1609 times
Last updated: 3/16/15, 8:10 AM