繁体   English   中英

如何继承 Odoo 的 POS 按钮

[英]How to inherit Odoo's POS buttons

我正在尝试在 POS 按钮中添加一些功能,特别是显示为“验证”的按钮。 要测试此链接https://odoo-development.readthedocs.io/en/latest/dev/pos/gui.html中的指南是否有效,我只需添加一个如下所示的 console.log:

odoo.define('my_module.js_file', function (require) {
    "use strict";

    var screens = require('point_of_sale.screens');

    screens.PaymentScreenWidget.include({
    init: function(parent, options) {
        this._super(parent, options);
        //My console log message
        console.log('Hello world!')
        this.pos.on('updateDebtHistory', function(partner_ids){
            this.update_debt_history(partner_ids);
      }, this);
    },
  });

但是该消息仅在 POS 结束加载数据时显示一次,而不是在我按下按钮时显示。 我在这里做错了什么?

要将您的代码添加到Validate按钮,您需要通过include方法修改支付屏幕小部件(您已经这样做了)。

如果您从浏览器中检查该按钮,您会发现它有一个 class next用于将事件处理程序绑定到单击JavaScript 事件。

示例

var screens = require('point_of_sale.screens');
var PaymentScreenWidget = screens.PaymentScreenWidget;

PaymentScreenWidget.include({

    validate_order: function(force_validation) {
        console.log('Hello world!');
        this._super(force_validation);
    },

});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM