Python代码:
@api.model
def test_method(self):
a= 10
b = 20
c = a+b
return c
jQuery:
var Model = require('web.Model');
$(document).ready(function() {
var test_model = new Model("MyClass");
test_model.call("test_method").then(function(c) {
console.log("res ult:" + JSON.stringify(result));
});
});
错误:
失踪取决于,
上面的代码将在 odoo 10 中工作,但不在 odoo 11 中。我想知道如何从 JS 调用 python 函数。