Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
5530 Visualizações

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
Cancelar

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

Melhor resposta

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
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
7
dez. 23
26003
2
ago. 24
6355
1
out. 22
24095
2
set. 21
12774
1
ago. 21
8329