Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
31132 มุมมอง

I m Trying to get the value returned from python to javascript.

python function -

def test(self,cr,uid,ids):

     a=3

     b=10

     if a<b:

         print "data",a,b

         return True

     else:

         return False


Js -

var module=new Model("ir.module.module");

   var data=module.call("test",[args]);

   alert(data);

can't we directly fetch value or do we need to explicitly pass value to javascript .

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

include js header in file

var Model = require('web.Model');

Define your function on python file:

@api.model
def function_name(self):
    data = {}
    return data


Then In your function call:

var model  = new Model('model_name').call('funcion_name').then(function(result){
    return result;
});
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

function1: function(parameters1,parameters2) { var variable = new instance.web.Model('model').call('test',[parameters1,parameters2]).then(function(result)

{

     $(".classtest").text(result);

            });

      },.
In "result" the value get from the python.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Dear Onkar

var mod = new instance.web.Model("account.budget.plan.budget");

period= mod.call("calculate_period").then(function(result){}

);

account.budget.plan.budget: your Model

calculate_period:  Your Method

II hope i helped you..

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ย. 20
4679
1
มิ.ย. 25
3779
6
ต.ค. 20
8629
2
ต.ค. 19
12176
1
ก.ย. 19
10651