Odoo Help


What should onchange methods return?

Torvald Baade Bringsvor
on 11/26/14, 8:43 PM 1,047 views

Seems the forum has some bugs, I was unable to enter text for the question. I'm on V8 so I'm after what has changed from V7 to V8. I have tried returning {'value' : {'fieldname etc... but the response that is returned to the client has another dictionary for 'value', with only some of the values changed in this onchange method.

Torvald Baade Bringsvor
on 11/27/14, 2:27 AM

Hi, try this for V8 onchange api.

    def onchange_field_name(self):
        value = self.field_name if self.field_name else 'Nothing'
        return {'value': {'field_name': value}}

You can return the value in self itself like,

    def onchange_field_name(self):
         self.message = "Dear %s" % (self.field_name or "")

The second approach works, but only for the field that triggered the onchange. If I want to update another field (a different column in a tree view) nothing happens. The first approach with the dictionary I'm not able to make work at all, I've looked at the response in Chrome and the values returned are the fields that have been modified in the onchange.

Torvald Baade Bringsvor
on 11/27/14, 5:20 AM
Baiju KS
On 11/26/14, 11:05 PM


onchange method should return a dictionary in following format :-  Eg:


'warning': {'Your Message'},

'value': {'field_name1': VALUE , 'field_name2': VALUE, 'field_name3': VALUE}


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: 11/26/14, 8:43 PM
Seen: 1047 times
Last updated: 3/16/15, 8:10 AM