JavaScript OpenERP:在父级的父级上调用_super()

JavaScript-OpenERP: Calling _super() on the parent of the parent

本文关键字:super 调用 OpenERP JavaScript      更新时间:2023-09-26

我需要覆盖OpenERP7中的JavaScript函数,以禁用一些我不需要的代码(隐藏"打印"按钮)。不幸的是,这个函数在父类上调用_super,所以我也需要调用它,但不调用我试图替换的函数。如何在父类的父级上调用_super?在这种情况下,extend()和include()都会产生相同的结果。

这是我的完整代码:

openerp.pos_fiscal_printer = function(instance) {
    var module = instance.point_of_sale;
    var _t = instance.web._t;

    module.ReceiptScreenWidget.include({
        show: function(){
            //this._super();
            var self = this;
            this.add_action_button({
                label: _t('Next Order'),
                icon: '/point_of_sale/static/src/img/icons/png48/go-next.png',
                click: function() { self.finishOrder(); },
            });
        },
    });
}

让show()函数通过jquery隐藏"打印按钮"。因此,您不会干扰父类逻辑的父级和父级(希望显示按钮)。