Odoo Help

Welcome!

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.

0

How can I make an asyncronious call and then return the result to the Odoo Client?

By
Henrik Norlin
on 11/24/15, 8:29 AM 435 views

This code gives me a QWeb Runtime Error when self.my_variable is set too late:

start: function() {

    var self = this;

    var tmp = this._super.apply(this, arguments);

    var defs = [];

    defs.push(my_model.call("my_method", [self.dataset.context]).then(function(result) {

        self.my_variable = result;

    }));

    $.when(tmp, defs).then(function() {

        self.$el.find('.my_class').html(QWeb.render("my_qweb", {pass_to_qweb: self.my_variable}));
    });

    return $.when(tmp, defs);

}

0
Henrik Norlin
On 11/24/15, 2:55 PM

The solution was simple:

start: function() {

    var self = this;

    var tmp = this._super.apply(this, arguments);

    var defs = [];

    defs.push(my_model.call("my_method", [self.dataset.context]).then(function(result) {

        self.my_variable = result;

        self.$el.find('.my_class').html(QWeb.render("my_qweb", {pass_to_qweb: self.my_variable}));

    }));

}

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

1 follower(s)

Stats

Asked: 11/24/15, 8:29 AM
Seen: 435 times
Last updated: 11/25/15, 5:21 AM