跳至内容
菜单
此问题已终结
1 回复
3922 查看

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.

形象
丢弃
最佳答案

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!

形象
丢弃

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

相关帖文 回复 查看 活动
0
11月 23
1911
0
5月 23
2657
0
12月 22
2469
0
10月 22
3668
0
6月 22
1730