Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
5708 Visninger

I need to call python file from JS. I am using model calling function but whenever It will call it returns false due to synchronous and asynchronous concept. Ex-

get_sale_total_price: function(id){

    var sale_total_price = false;

    Model.call('get_sale_total_price', [id]).then(function(callback) {

        if (callback){

            sale_total_price = callback.price;

        }

    }

    return sale_total_price;

}

Is there any ways to fix without set-interval function?

Avatar
Kassér

code inside model.call executes after all lines in your function executes.

Bedste svar

You Have to Use deferred and resolve

or Try This :

rpc.query({

    model: 'your.model',       // python model name

    method: 'get_sale_total_price',      // python method name

    args: [args],      // args

}).then(function (result) {
    sale_total_price = result;

});

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
7
dec. 23
26284
2
aug. 24
6669
1
okt. 22
24376
2
sep. 21
13088
1
aug. 21
8574