Odoo Help

1

What should onchange methods return?

By
Torvald Baade Bringsvor
on 11/26/14, 8:43 PM 894 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
2

Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
3617
| 5 4 9
Pondicherry, India
--Dhinesh - Technical Consultant, Sodexis Inc--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks. Did code in Java, PHP.

Contact me at: dvdhinesh.mail@gmail.com

Dhinesh - Technical Consultant, Sodexis Inc
On 11/27/14, 3:11 AM

Hi, try this for V8 onchange api.

    @api.onchange('field_name')
    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,

    @api.onchange('field_name')
    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
2

Baiju KS

--Baiju KS--
3194
| 5 5 8
Kochi, India
--Baiju KS--
ODOO technical

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju KS
On 11/26/14, 11:05 PM

Hi,,

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.

Register

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)

Stats

Asked: 11/26/14, 8:43 PM
Seen: 894 times
Last updated: 3/16/15, 8:10 AM