تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
2414 أدوات العرض

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


الصورة الرمزية
إهمال
أفضل إجابة

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.

الصورة الرمزية
إهمال

how can i override something on the NumberBuffer class in Odoo17

أفضل إجابة

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

الصورة الرمزية
إهمال

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!

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
نوفمبر 24
1159
4
أكتوبر 24
3396
0
أكتوبر 22
5094
0
سبتمبر 22
38
1
مارس 22
6632