Can anyone give me minimal code so that any method I can override for JS method? in pos odoo
changeMode(mode) { if (!this.hasPriceControlRights && mode === 'price' ) { return; } if (!this.hasManualDiscount && mode === 'discount') { return; } this.trigger('set-numpad-mode', { mode }); }
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
Hi,
In Odoo 15, you can override a JavaScript method by creating a custom module and using the patch utility from OWL. First, include your custom JS file in the point_of_sale.assets bundle in your module’s __manifest__.py. Inside the JS file, import the component you want to override (e.g., Numpad in POS) and use patch to extend its prototype. For example, to override the changeMode method, write:
/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import { Numpad } from "@point_of_sale/app/screens/numpad/numpad";
patch(Numpad.prototype, "my_pos_custom_numpad_patch", {
changeMode(mode) {
console.log("Custom logic for changeMode", mode);
this.trigger('set-numpad-mode', { mode });
},
});
After restarting Odoo and upgrading the module, your custom logic will replace or extend the original method. This is the clean and recommended way to override JS methods in Odoo 15.
Hope it helps
Inherits the class of the method,Rewriting method
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
2
مايو 22
|
14629 | ||
|
2
أبريل 22
|
4729 | ||
|
1
يوليو 25
|
4131 | ||
|
10
ديسمبر 24
|
32368 | ||
|
1
نوفمبر 23
|
10653 |