Can anyone give me minimal code so that any method I can override for JS method?
changeMode(mode) { if (!this.hasPriceControlRights && mode === 'price' ) { return; } if (!this.hasManualDiscount && mode === 'discount') { return; } this.trigger('set-numpad-mode', { mode }); }
Advertisement
Answer
You need to extend in-place a class in the registry, it is documented in the point of sale ClassRegistry.
Example
odoo.define('MODULE_NAME.NumpadWidget', function(require) { 'use strict'; const NumpadWidget = require('point_of_sale.NumpadWidget'); const Registries = require('point_of_sale.Registries'); const CustomNumpadWidget = NumpadWidget => class extends NumpadWidget { changeMode(mode) { return super.changeMode(mode); } }; Registries.Component.extend(NumpadWidget, CustomNumpadWidget); return NumpadWidget; });