Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2668 Lượt xem

Hello everyone,

I want to replace in Payment Screen of the pos the +10, +20, +50 to +1000, +5000, +10000.

for that i'm trying to inherit the NumberBuffer class to add my elements in the const Set INPUT_KEYS.

var NumberBuffer = require('point_of_sale.NumberBuffer');

NumberBuffer.include({
init: function() {
var self = this;
this._super.apply(this, arguments);
this.INPUT_KEYS.add('+1000');
this.INPUT_KEYS.add('+5000');
this.INPUT_KEYS.add('+10000');
},});

this code give me error that : NumberBuffer.include is not a function TypeError: NumberBuffer.include is not a function 

so i don't what is the best way to achieve my goal.

Thanks for any suggestion


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Edit: I was able to solve it


I needed to overide the _updateBuffer on the NumberBuffer class, what I did and worked was overriding the function as a parameter of the object. This was the code I used


odoo.define('my_pos_module.NumberBuffer', function(require) {

"use strict";
var NumberBuffer = require('point_of_sale.NumberBuffer');


​NumberBuffer._updateBuffer = async function (input) {
​// put your changes here
​}

return NumberBuffer;
});

So everytime you need to override something on the NumberBuffer class this is how it worked for me.

Ảnh đại diện
Huỷ bỏ

how can i override something on the NumberBuffer class in Odoo17

Câu trả lời hay nhất

No, i abandon the task. maybe odoo have to give option to the user to choose his preferences values

Ảnh đại diện
Huỷ bỏ

Sad, okay, thanks anyway.
I guess the issue with the NumberBuffer class is that it is a singleton and not the average class that Odoo uses for the models.
I tried with the "include" function, the "extend" function and even tried to extend the class in the Javascript way but none of those worked.

I was able to solve it, if you need the solution check my edited answer!

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 24
1631
4
thg 10 24
4089
0
thg 10 22
5303
0
thg 9 22
38
1
thg 3 22
6963