Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

726
Vistas
How to override js method in Odoo 15?

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 });
    }
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

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;
 });
about 4 years ago · Juan Pablo Isaza Denunciar

0

This might help you, I inherit the point of sale widget screen as the below code,

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;
},


});

});

It work's fine with the validation of order_paid not less than 30.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda