This question has been flagged
1 Reply
3060 Views

I tried  to super the function validateOrder(isForceValidate)...


var pos_model = require('point_of_sale.models');
const PaymentScreen = require('point_of_sale.PaymentScreen');

var models = pos_model.PosModel.prototype.models;

var rpc = require('web.rpc');


    class PosScreen extends PaymentScreen {



     constructor(isForceValidate) {
        super(isForceValidate);
        this.template = 'PaymentScreen';
  }

    async validateOrder(isForceValidate) {
//            var self = this;
            super.validateOrder(isForceValidate);
            console.log("validate==========================>")


        }


    }


but the console is not working when click validate button...how to super the function.

Avatar
Discard
Best Answer

Hi Sangeeth,

I might be late for this. But it might be helpful for someone else. You can override the validate function as follows:

odoo.define('module_name.POSValidateOverride', function(require) {
    'use strict';

    const PaymentScreen = require('point_of_sale.PaymentScreen');
    const Registries = require('point_of_sale.Registries');

    const POSValidateOverride = PaymentScreen =>
        class extends PaymentScreen {
            /**
             * @override
             */
            async validateOrder(isForceValidate) {
                console.log('POSValidateOverride::validateOrder(): successfully overridden');
                await super.validateOrder(isForceValidate);
                // Add your code
            }
        };

    Registries.Component.extend(PaymentScreen, POSValidateOverride);

    return PaymentScreen;
});

Hope that helps!

Avatar
Discard

This is absolute brilliant answer to the point for Odoo Version 14.