跳至内容
菜单
此问题已终结
2 回复
5583 查看

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?

形象
丢弃

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

最佳答案

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;

});

形象
丢弃
相关帖文 回复 查看 活动
7
12月 23
26107
2
8月 24
6468
1
10月 22
24182
2
9月 21
12871
1
8月 21
8399