跳至內容
選單
此問題已被標幟
1 回覆
3914 瀏覽次數

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
1910
0
5月 23
2655
0
12月 22
2469
0
10月 22
3667
0
6月 22
1730