¿Alguien puede darme un código mínimo para que pueda anular cualquier método para el método JS?
changeMode(mode) { if (!this.hasPriceControlRights && mode === 'price' ) { return; } if (!this.hasManualDiscount && mode === 'discount') { return; } this.trigger('set-numpad-mode', { mode }); }Debe extender una clase en el lugar en el registro, está documentado en el ClassRegistry de punto de venta.
Ejemplo
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; });Esto podría ayudarlo, heredo la pantalla del widget de punto de venta como el siguiente código,
odoo.define('js_frame_work_sample.jsframework', function (require) { "use strict"; var Screens = require('point_of_sale.screens'); var core = require('web.core'); var _t = core._t; Screens.PaymentScreenWidget.include({ order_is_valid: function(force_validation) { var self = this; var order = this.pos.get_order(); // FIXME: this check is there because the backend is unable to // process empty orders. This is not the right place to fix it. var order_paid = order.get_total_paid() console.log("order Paid", order_paid) if (order_paid <= 30) { alert("The sub total is below 30, No purchase") return false; } if (order.get_orderlines().length === 0) { this.gui.show_popup('error',{ 'title': _t('Empty Order'), 'body': _t('There must be at least one product in your order before it can be validated'), }); return false; } if (!order.is_paid() || this.invoicing) { return false; } // The exact amount must be paid if there is no cash payment method defined. if (Math.abs(order.get_total_with_tax() - order.get_total_paid()) > 0.00001) { var cash = false; for (var i = 0; i < this.pos.cashregisters.length; i++) { cash = cash || (this.pos.cashregisters[i].journal.type === 'cash'); } if (!cash) { this.gui.show_popup('error',{ title: _t('Cannot return change without a cash payment method'), body: _t('There is no cash payment method available in this point of sale to handle the change.\n\n Please pay the exact amount or add a cash payment method in the point of sale configuration'), }); return false; } } // if the change is too large, it's probably an input error, make the user confirm. if (!force_validation && order.get_total_with_tax() > 0 && (order.get_total_with_tax() * 1000 < order.get_total_paid())) { this.gui.show_popup('confirm',{ title: _t('Please Confirm Large Amount'), body: _t('Are you sure that the customer wants to pay') + ' ' + this.format_currency(order.get_total_paid()) + ' ' + _t('for an order of') + ' ' + this.format_currency(order.get_total_with_tax()) + ' ' + _t('? Clicking "Confirm" will validate the payment.'), confirm: function() { self.validate_order('confirm'); }, }); return false; } return true; }, }); });Funciona bien con la validación de order_paid no menos de 30.