在编辑表单时,如何在JS函数中获取当前模型数据,在Odoo 13中
编辑表单时,我想在JS中获取当前模型字段值,并通过AJAX帖子到控制器,然后打印控制器响应结果。
但是现在我无法在JS中获得当前模块的字段和值。我该如何访问它们? 我需要访问当前表单值,而不是数据库数据。
odoo.define('jy.abc2', function(require) {
'use strict';
var self=this;
function tab1(){
console.log('in setInterval');
var checkDate = $('#checkDate').val();
var orderNo = $('#orderNo').val();
//var tmpmodel= self.model; //cann't access that
//console.log(tmpmodel);
$.ajax({
type: "POST",
dataType: "json",
url:"/jy/abc/testjson",
data: {
params:{
'hotelSeq': 111,
'orderNo': 'orderNo',
//'tmpmodel':tmpmodel,
}
},
success: function (msg) {
console.log(msg);
},
error: function () {
//alert("false")
}
});
}
$(document).ready(function() {
var init = setInterval(tab1,5000);
});
})
When editing the form, I want to get current model field value in js, and through Ajax post to the controller, and then print the controller response result.
But now I can't get the fields and values of the current module in JS. How can I access them?
i need access the current form value,not database data.
odoo.define('jy.abc2', function(require) {
'use strict';
var self=this;
function tab1(){
console.log('in setInterval');
var checkDate = $('#checkDate').val();
var orderNo = $('#orderNo').val();
//var tmpmodel= self.model; //cann't access that
//console.log(tmpmodel);
$.ajax({
type: "POST",
dataType: "json",
url:"/jy/abc/testjson",
data: {
params:{
'hotelSeq': 111,
'orderNo': 'orderNo',
//'tmpmodel':tmpmodel,
}
},
success: function (msg) {
console.log(msg);
},
error: function () {
//alert("false")
}
});
}
$(document).ready(function() {
var init = setInterval(tab1,5000);
});
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论