在编辑表单时,如何在JS函数中获取当前模型数据,在Odoo 13中

发布于 2025-02-13 22:10:39 字数 1037 浏览 0 评论 0原文

编辑表单时,我想在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文