【问题标题】:How to inherit Odoo's POS buttons如何继承 Odoo POS 按钮
【发布时间】:2020-07-20 09:15:05
【问题描述】:

我正在尝试在 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 结束加载数据时显示一次,而不是在我按下按钮时显示。我在这里做错了什么?

【问题讨论】:

    标签: javascript customization pos odoo-13


    【解决方案1】:

    要将您的代码添加到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);
        },
    
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-30
      • 1970-01-01
      • 2022-12-23
      相关资源
      最近更新 更多