跳至內容
選單
此問題已被標幟
1 回覆
13505 瀏覽次數

Hi, i replaced gui.js in pos module and using the default js that i modify a littlebit. and i got this error while i want to use my shortcut that i've already created.

Cannot read property 'slice' of undefined
http://localhost:4227/web/content/1149-878d886/point_of_sale.assets.js:368
Traceback:
TypeError: Cannot read property 'slice' of undefined
    at Class.numpad_input (http://localhost:4227/web/content/1149-878d886/point_of_sale.assets.js:368:350)


and my numpad_input class is:

        numpad_input: function(buffer, input, options) {
            var newbuf  = buffer.slice(0);
            options = options || {};
            var newbuf_float  = newbuf === '-' ? newbuf : field_utils.parse.float(newbuf);
            var decimal_point = _t.database.parameters.decimal_point;
            if (input === decimal_point) {
                if (options.firstinput) {
                    newbuf = "0.";
                }else if (!newbuf.length || newbuf === '-') {
                    newbuf += "0.";
                } else if (newbuf.indexOf(decimal_point) < 0){
                    newbuf = newbuf + decimal_point;
                }
            } else if (input === 'CLEAR') {
                newbuf = "";
            } else if (input === 'BACKSPACE') {
                newbuf = newbuf.substring(0,newbuf.length - 1);
            } else if (input === '+') {
                if ( newbuf[0] === '-' ) {
                    newbuf = newbuf.substring(1,newbuf.length);
                }
            } else if (input === '-') {
                if (options.firstinput) {
                    newbuf = '-0';
                } else if ( newbuf[0] === '-' ) {
                    newbuf = newbuf.substring(1,newbuf.length);
                } else {
                    newbuf = '-' + newbuf;
                }
            } else if (input[0] === '+' && !isNaN(parseFloat(input))) {
                newbuf = this.chrome.format_currency_no_symbol(newbuf_float + parseFloat(input));
            } else if (!isNaN(parseInt(input))) {
                if (options.firstinput) {
                    newbuf = '' + input;
                } else {
                    newbuf += input;
                }
            }
            if (newbuf === "-") {
                newbuf = "";
            }
            // End of input buffer at 12 characters.
            if (newbuf.length > buffer.length && newbuf.length > 16) {
                this.play_sound('bell');
                return buffer.slice(0);
            } 
            return newbuf;
        },



any idea why i got this error?

頭像
捨棄
最佳答案

Hi Hansel, 

It seems buffer is undefined.

You can check buffer value with console.log("buffer.....", buffer) and result will be undefined. You are trying to apply slice() with undefined value so it is not working. Make sure you are passing correct buffer value from screens.js. ie. this.gui.numpad_input(this.inputbuffer, input, {params})

Please put a check before slice as below:

if (buffer !== undefined && !isNaN(buffer)){

 var newbuf  = buffer.slice(0);

}


Hope you got the answer

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

頭像
捨棄
作者

hi! thanks for the help. looklike its still not working. i still got the same error. by the way, how to use your suggestion console.log("buffer.....", buffer) ? i got no clue where to use it. thanks in advance.