Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
2610 Vizualizări

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


Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează

how can i override something on the NumberBuffer class in Odoo17

Cel mai bun răspuns

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

Imagine profil
Abandonează

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 Răspunsuri Vizualizări Activitate
1
nov. 24
1579
4
oct. 24
3960
0
oct. 22
5254
0
sept. 22
38
1
mar. 22
6862