【问题标题】:How can add a button in pos in payment section in odoo 12?如何在odoo 12的付款部分的pos中添加按钮?
【发布时间】:2021-09-11 01:00:44
【问题描述】:

我需要在清除订单行的 POS 中放置一个按钮取消支付部分,但我创建的按钮实际上是在产品屏幕中,我尝试了这个:

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="ClearCartLine">
    <div class='control-button'>
        Boton prueba
    </div>
</t>
</templates>

js 是这样的:

odoo.define('clear_button_fun.pos_view',function(require){ “使用严格”;

var screens = require('point_of_sale.screens');
var gui = require('point_of_sale.gui');
var core = require('web.core');

var ClearCartLine = screens.ActionButtonWidget.extend({
    template: "ClearCartLine",

    button_click: function(){
    var self = this;
    this.clear_button_fun();
    },

    clear_button_fun(){
    var order = this.pos.get_order();
    order.remove_orderline(order.get_selected_orderline())
    },
});
screens.define_action_button({'name': 'clear_button_fun','widget': ClearCartLine,});

});

我需要这样的按钮:

I need the button in position like that:

【问题讨论】:

    标签: javascript odoo


    【解决方案1】:

    您可以更改PaymentscreenWidge 模板以添加按钮

    示例:

    <t t-extend="PaymentScreenWidget">
        <t t-jquery="div.payment-buttons" t-operation="append">
            <div class='button highlight js_clear_orderline'>
                <i class='fa fa-cog' role="img" aria-label="Clear" title="Clear"/>
                <span class='js_clear_orderline'>
                    Boton prueba
                </span>
            </div>
        </t>
    </t>
    

    然后通过改变renderElement函数在PaymentScreenWidget中定义点击事件

    示例:

    var screens = require('point_of_sale.screens');
    screens.PaymentScreenWidget.include({
        renderElement: function() {
            var self = this;
            this._super();
            this.$('.js_clear_orderline').click(function(){
                
            });
        },
    });
    

    【讨论】:

    • 按钮添加成功了吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-10
    • 1970-01-01
    • 2020-01-29
    • 2020-07-20
    • 2019-05-03
    • 1970-01-01
    相关资源
    最近更新 更多