0
votes

I need to put one button un payment section in POS that clear order line, but the button that i've created actually is in product screen, i tried this:

<?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>

and the js is this:

odoo.define('clear_button_fun.pos_view',function(require){ "use strict";

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:

I need the button in position like that:

1

1 Answers

0
votes

You can alter the PaymentscreenWidge template to add the button

Example:

<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>

Then define the click event in the PaymentScreenWidget by altering the renderElement function

Example:

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