Zahid Anwar
December 4, 2024
First of all create an xml file with name custom_button.xml inside :
your_app>static>src>app>custom_button>custom_button.xml
your_app/
├── __init__.py
├── __manifest__.py
├── static/
│ └── src/
│ └── app/
│ └── custom_button/
│ └── custom_button.xml
│ └── custom_button.js
<?xml version=”1.0″ encoding=”UTF-8″?>
<templates id=”template” xml:space=”preserve”>
<t t-name=”pos_usc.ControlButtons” t-inherit=”point_of_sale.ControlButtons” t-inherit-mode=”extension”>
<xpath expr=”//button[@class=’btn btn-light btn-lg flex-shrink-0 ms-auto’]” position=”replace”>
<button class=”btn btn-success btn-lg flex-shrink-0 ms-auto” t-on-click=”() => this.onClickPopupSingleField()”>Custom Button</button>
</xpath>
</t>
</templates>
/**@odoo-module **/
import { ControlButtons } from "@point_of_sale/app/screens/product_screen/control_buttons/control_buttons";
import { patch } from "@web/core/utils/patch";
patch(ControlButtons.prototype, {
async onClickPopupSingleField() {
console.log('button click');
}
});
'assets': {
'point_of_sale._assets_pos': [
'your_app/static/src/app/custom_button/custom_button.js',
'your_app/static/src/app/custom_button/custom_button.xml',
],
},
That’s it! You’ve added the custom buttons in point of sale!