Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
2366 Prikazi

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


Avatar
Opusti
Best Answer

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.

Avatar
Opusti

how can i override something on the NumberBuffer class in Odoo17

Best Answer

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

Avatar
Opusti

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!

Related Posts Odgovori Prikazi Aktivnost
1
nov. 24
1103
4
okt. 24
3326
0
okt. 22
5068
0
sep. 22
38
1
mar. 22
6578