[英]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.