How to do it...

Follow these steps to add the 5% discount action button on the keyboard panel of the Point of Sale application:

  1. 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
});

});
  1. 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>
  1. 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset