İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
5616 Görünümler

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
Vazgeç

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

En İyi Yanıt

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
7
Ara 23
26166
2
Ağu 24
6543
1
Eki 22
24268
2
Eyl 21
12968
1
Ağu 21
8467