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.


passing field values with context in wizard

on 3/25/14, 4:48 AM 4,477 views

Hello, I am trying to pass in values from some fields in a wizard that I created. I am using the context dictionary in the xml file to pass the value of the field, but when I use the context variable in the .py file, then it doesnt get the value that I passed in. Its like its not finding the key name that Im giving it on the xml form.

Here is an example in the xml file:

<field name="amount" context="{'amount_val': amount}"/>

Here is an example in the .py file:

def make_payment(self, cr, uid, vals, context=None):
    amount = context.get('amount_val', 1.00)

When I enter an amount of 100.00 in the wizard, all that it gets is the default value 1.00. So I was wondering what I am doing wrong here? Thank you

What exactly are you trying to do?

When is make_payment called? Using the context as attribute in the xml tag will only pass the context to the field amount, when you change/create it.

René Schuster
on 3/25/14, 6:13 AM
On 3/25/14, 12:17 PM

I think you should put the context="{'amount_val': amount}" in the button tag that calls your make_payment method.

<button name="make_payment" type="object" context="{'amount_val': amount}"/> or something like that.

Very good. That did the trick. Thank you

on 3/25/14, 12:28 PM

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: 3/25/14, 4:48 AM
Seen: 4477 times
Last updated: 3/16/15, 8:10 AM