簡體   English   中英

單擊按鈕odoo時如何調用該函數

[英]How to call the function when click on button odoo

在此處輸入圖片說明 單擊按鈕時如何調用該函數。 我創建了按鈕並打印(控制台上的Hello)。 它會打印,但是當我定義簡單地將兩個數字相加的函數時,就會出錯。

我使用以下代碼:

var FormCustomControllerMixin = {
   init: function (parent, model, renderer, params) {
       this.importEnabled = params.importEnabled;
   },

   _getLocation : function(){
       var a=10;
       var b=20;
       var c= a+b;
       console.log(c);
   },

   _bindImport: function () {
       if (!this.$buttons) {
           return;
       }
       var self = this;
       this.$buttons.on('click', '.o_button_custom_form', function () {
           console.log('Hello');
           a=self._getLocation();
         console.log(a);
       });
   }
};

你好是打印,但不執行加法。

你有這樣嘗試過嗎?

a=_getLocation();

我得到了解決方案的getlocation函數在FormCustomCOntrollerMixin內部不起作用。

var a = function getLocation () {
        var a=10;
        var b=20;
        var c= a+b;
        console.log(c);
        return
    }



var FormCustomControllerMixin = {

    init: function (parent, model, renderer, params) {
        this.importEnabled = params.importEnabled;
    }
    },

    _bindImport: function () {
        if (!this.$buttons) {
            return;
        }
        var self = this;
        debugger;
        this.$buttons.on('click', '.o_button_custom_form', function () {
            var b = a();

        });
    }
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM