Community mailing list archives

Getting field in javascript

- 01/28/2015 03:21:26

Dear all,,


I work on odoo 8 and I want to get the value of  model field in javascript code to do certain action when this field  has certain value.


I tried the following idea but it doesn’t work:

var model = new instance.web.Model("survey.user_input");"get_state", {context: new instance.web.CompoundContext()}).then(function(result) { alert(result)});



and in the survey.user_input I created the following function


def get_state(self, cr, uid, automatic=False, context=None):


        user_input_ids =, uid, [],context=context)

        id = len(user_input_ids)-1

        survey_obj = self.browse(cr, uid, id, context=context)

        return {'state': survey_obj.state}



How can this be performed?


Thanks in advance.