我正在尝试在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
方法修改付款屏幕小部件(您已经完成了)。
[如果从浏览器中检查按钮,您会发现它具有next
类,该类用于将事件处理程序绑定到click 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);
},
});