Follow these steps to add the 5% discount action button on the keyboard panel of the Point of Sale application:
- Add the following code to the /static/src/js/pos_demo.js file, which will define the action button:
odoo.define('pos_demo.custom', function (require) {
"use strict";
var screens = require('point_of_sale.screens');
var discount_button = screens.ActionButtonWidget.extend({
template: 'BtnDiscount',
button_click: function () {
var order = this.pos.get_order();
if (order.selected_orderline) {
order.selected_orderline.set_discount(5);
}
}
});
screens.define_action_button({
'name': 'discount_btn',
'widget': discount_button
});
});
- Add the QWeb template for the button in the /static/src/xml/pos_demo.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="BtnDiscount">
<div class='control-button'>
<i class='fa fa-gift' /> 5% discount
</div>
</t>
</templates>
- Register the QWeb template in the manifest file as follows:
'qweb': [
'static/src/xml/pos_demo.xml'
]
Update the pos_demo module to apply the changes. After that, you will be able to see a 5% discount button above the keyboard:
After clicking this, the discount will be applied on the selected order line.