SlideShare a Scribd company logo
6
Most read
7
Most read
15
Most read
How to add custom
button in POS Odoo 17
Enterprise
Introduction
Enterprise
The Odoo Javascript framework uses a custom component
framework called Owl.
Odoo 17 uses relies on the Odoo Web Library (OWL) for web
development. It employs OWL concepts and principles in its POS
system, with JavaScript code.
To create a new custom button in the Odoo 17 POS screen, we
need to create a new module which uses OWL Framework and
integrate the JS and XML files for the buttons in the point_of_sale
addon module.
Enterprise
Let’s create our custom module pos_custom_button. We will discuss
about creating two different buttons, one in the Product screen and
the other in the Payment Screen of POS. The basic structure of the
module is as
Enterprise
To implement the task to create custom Popup buttons, we use the
OWL concept by creating JS and XML files. In the manifest file of the
module, we need to add these files as the POS assets of point_of_sale
directory.
ie, in the manifest add the code for assets key as:
'assets': {
'point_of_sale._assets_pos': [
'pos_custom_button/static/src/js/*',
'pos_custom_button/static/src/js/PopUp/*',
'pos_custom_button/static/src/xml/pos_product_screen_button.xml',
'pos_custom_button/static/src/xml/pos_pop_up.xml',
]
},
Enterprise
Navigate to the static/src/xml directory and create a new xml file. We
need two xml files.
● Here, pos_pop_up.xml for designing the simple structure of
the pop up window which is to be shown on clicking the button.
● pos_product_screen_button.xml which inherits the addon
templates to show the custom buttons, one in the product
screen and the other on the payment screen.
Creating XML files
Enterprise
Using the <templates> tag, design the pop up in xml. pos_custom_button is the
module name and CustomAlertPopup is the pop up name
<t t-name="pos_custom_button.CustomAlertPopup" owl="1">
<div class="popup custom_popup">
<div class="modal-header justify-content-center">
<h2 class="modal-title">
<t t-esc="props.title"/></h2></div>
<div class="modal-body custom-form-view">
<form><div class="col d-flex justify-content-between align-items-
center p-3">
Pop up button clicked from POS
</div>
</form>
</div>
<div class="footer footer-flex modal-footer justify-content-end">
<div class="button cancel btn btn-lg btn-primary"
t-on-click="cancel">Close
<t t-esc="props.closePopup"/>
</div>
</div></div>
</t>
Enterprise
It's important to specify the module and necessary screens in the JS file by
utilizing /**@odoo-module **/ to define the module. This ensures that the
JavaScript functionalities are properly associated with the Odoo module and its
relevant screens.
The js code which calls this pop up window template can be set as
/** @odoo-module */
import { AbstractAwaitablePopup } from
"@point_of_sale/app/popup/abstract_awaitable_popup";
/**
* CustomAlertPopup component for displaying messages as an alert popup.
* Inherits from AbstractAwaitablePopup.
*/
export class CustomAlertPopup extends AbstractAwaitablePopup {
static template = "pos_custom_button.CustomAlertPopup";
}
Enterprise
After that, let’s create the custom buttons. The code for adding the
template named CreateButton for the button in the Product screen is
as:
<t t-name="point_of_sale.CreateButton">
<button class="control-button btn btn-light rounded-0 fw-bolder"
t-on-click="() => this.onClick()">
<i class="fa fa-pencil-square" role="img"
aria-label="Custom Alert" title="Custom Alert"/>
<span> </span>
<span>Custom Button 1</span>
</button>
</t>
Enterprise
This will create the button as
Enterprise
For the button in the Payment screen, here is the code for adding the
template named CreateButton:
<t t-name="pos_button.PaymentScreenButtons"
t-inherit="point_of_sale.PaymentScreenButtons"
t-inherit-mode="extension">
<xpath expr="//div[hasclass('payment-buttons')]" position="inside">
<button class="button button-partial-payment btn btn-light py-3 text-start
rounded-0 border-bottom"
t-on-click="onClick">
<i class="fa fa-money me-2"/>Custom Button 2
</button>
</xpath>
</t>
Enterprise
This will create the button as
Enterprise
The JS file must be added after the button. For the first button created
on the Product screen, add the following modules for extending the
product screen js codes.
/** @odoo-module */
import { ProductScreen } from
"@point_of_sale/app/screens/product_screen/product_screen";
import { useService } from "@web/core/utils/hooks";
import { Component } from "@odoo/owl";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { CustomAlertPopup } from "@pos_custom_button/js/PopUp/popup_button";
Enterprise
Then, add the custom CreateButton component and add the onClick()
method,
export class CreateButton extends Component {
static template = "point_of_sale.CreateButton";
/* Setup function to initialize the component.*/
setup() { this.pos = usePos();
this.popup = useService("popup");
}
/* Click event handler for the create button.*/
async onClick() {
this.popup.add(CustomAlertPopup)
}}
/* Add the OrderlineProduct CreateButton component to the control buttons in the
ProductScreen.*/
ProductScreen.addControlButton({component: CreateButton,});
Enterprise
Now, just click on the Custom Button 1 on the Product screen. It’ll show
the popup like
Enterprise
For the second button created on the Payment screen, add the js code.
/**@odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { PaymentScreen } from
"@point_of_sale/app/screens/payment_screen/payment_screen";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { CustomAlertPopup } from
"@pos_custom_button/js/PopUp/popup_button";
import { patch } from "@web/core/utils/patch";
patch(PaymentScreen.prototype, {
async onClick() { this.popup.add(CustomAlertPopup)
}})
Enterprise
Then, just click on the Custom Button on the Payment screen. It’ll
show the popup like
Enterprise
This is how custom buttons are incorporated into the Product and
Payment screens in the point of sale interface.
Additionally, you have the flexibility to position the button wherever
desired by specifying the location and supplying the XPath. The
assets files are integrated into the manifest files, and the button can
be added via both JS and XML files.
For More Info.
Check our company website for related blogs
and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com

More Related Content

PPTX
How to Load Custom Field to POS in Odoo 17 - Odoo 17 Slides
DOCX
Laporan praktikum botani tumbuhan tinggi 2 sub classis magnoliidae
PPTX
Prezentacja o sobie
PPTX
How to modify_create components control buttons in Pos odoo.pptx
PPTX
How to Create a Custom Screen in Odoo 17 POS
PPTX
How To Extend Odoo Form View using js_class_
PPTX
How to perform product search based on a custom field from the PoS screen of ...
PPTX
How to Create a Dynamic Snippet in Odoo 17
How to Load Custom Field to POS in Odoo 17 - Odoo 17 Slides
Laporan praktikum botani tumbuhan tinggi 2 sub classis magnoliidae
Prezentacja o sobie
How to modify_create components control buttons in Pos odoo.pptx
How to Create a Custom Screen in Odoo 17 POS
How To Extend Odoo Form View using js_class_
How to perform product search based on a custom field from the PoS screen of ...
How to Create a Dynamic Snippet in Odoo 17

Similar to How to Add a Custom Button in Pos Odoo 17 (20)

PPTX
How to Add a Custom Button in Odoo 18 POS Screen
PPTX
How to Create & Manage a Dashboard Using OWL in Odoo 17
PDF
Dojo1.0_Tutorials
PDF
Dojo1.0_Tutorials
PDF
Devoxx 2014-webComponents
PPTX
How to Create and Manage Wizard in Odoo 17
PPTX
Tips On Trick Odoo Add-On.pptx
PPTX
URLs and Routing in the Odoo 17 Website App
PPTX
How to Empty a One2Many Field in Odoo 17
PPTX
How to make a component and add it to systray in Odoo
PPTX
How to Create a Theme Module in Odoo 17 - Odoo 17 Slides
PPTX
How to Add New Item in CogMenu in Odoo 17
PPTX
Pinned Sites IE 9 Lightup
PPTX
How To Add Smart Buttons In Odoo 17 - Odoo Slides
PDF
Web components with Angular
PPTX
Report Actions In Odoo 17 - Odoo 17 Slides
PDF
Visual Studio tool windows
PDF
Solid angular
DOCX
How To Add A Custom Button To The Chatter In Odoo 18 ?
PPTX
How to Create a Popup in Odoo POS 17 - Odoo 17 Slides
How to Add a Custom Button in Odoo 18 POS Screen
How to Create & Manage a Dashboard Using OWL in Odoo 17
Dojo1.0_Tutorials
Dojo1.0_Tutorials
Devoxx 2014-webComponents
How to Create and Manage Wizard in Odoo 17
Tips On Trick Odoo Add-On.pptx
URLs and Routing in the Odoo 17 Website App
How to Empty a One2Many Field in Odoo 17
How to make a component and add it to systray in Odoo
How to Create a Theme Module in Odoo 17 - Odoo 17 Slides
How to Add New Item in CogMenu in Odoo 17
Pinned Sites IE 9 Lightup
How To Add Smart Buttons In Odoo 17 - Odoo Slides
Web components with Angular
Report Actions In Odoo 17 - Odoo 17 Slides
Visual Studio tool windows
Solid angular
How To Add A Custom Button To The Chatter In Odoo 18 ?
How to Create a Popup in Odoo POS 17 - Odoo 17 Slides
Ad

More from Celine George (20)

PPTX
How to Implement OWL Notification Service in Odoo 18
PPTX
Tracking Profit Margins in Sales Orders with Odoo 18
PPTX
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
PPTX
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
PPTX
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
PPTX
How to Add New Applicants in Odoo 18 Recruitment
PPTX
How to Analyze the Recruitment Process in Odoo 18 Recruitment
PPTX
How to Manage Referral Reporting in Odoo 18 Referrals
PPTX
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
How to Manage Bill Control Policy in Odoo 18
PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PPTX
Odoo 18 Sales_ Managing Quotation Validity
PPTX
How to Manage Global Discount in Odoo 18 POS
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
How to Implement OWL Notification Service in Odoo 18
Tracking Profit Margins in Sales Orders with Odoo 18
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
How to Add New Applicants in Odoo 18 Recruitment
How to Analyze the Recruitment Process in Odoo 18 Recruitment
How to Manage Referral Reporting in Odoo 18 Referrals
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
Revamp in MTO Odoo 18 Inventory - Odoo Slides
How to Manage Starshipit in Odoo 18 - Odoo Slides
How to Manage Bill Control Policy in Odoo 18
How to Manage Loyalty Points in Odoo 18 Sales
Odoo 18 Sales_ Managing Quotation Validity
How to Manage Global Discount in Odoo 18 POS
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Tips Management in Odoo 18 POS - Odoo Slides
How to Close Subscription in Odoo 18 - Odoo Slides
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
How to Track Skills & Contracts Using Odoo 18 Employee
Ad

Recently uploaded (20)

PDF
Insiders guide to clinical Medicine.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Lesson notes of climatology university.
PDF
Computing-Curriculum for Schools in Ghana
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Institutional Correction lecture only . . .
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
RMMM.pdf make it easy to upload and study
PDF
01-Introduction-to-Information-Management.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Insiders guide to clinical Medicine.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
STATICS OF THE RIGID BODIES Hibbelers.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Lesson notes of climatology university.
Computing-Curriculum for Schools in Ghana
Microbial disease of the cardiovascular and lymphatic systems
TR - Agricultural Crops Production NC III.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Institutional Correction lecture only . . .
O5-L3 Freight Transport Ops (International) V1.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Renaissance Architecture: A Journey from Faith to Humanism
VCE English Exam - Section C Student Revision Booklet
Supply Chain Operations Speaking Notes -ICLT Program
RMMM.pdf make it easy to upload and study
01-Introduction-to-Information-Management.pdf
Basic Mud Logging Guide for educational purpose
FourierSeries-QuestionsWithAnswers(Part-A).pdf

How to Add a Custom Button in Pos Odoo 17

  • 1. How to add custom button in POS Odoo 17 Enterprise
  • 2. Introduction Enterprise The Odoo Javascript framework uses a custom component framework called Owl. Odoo 17 uses relies on the Odoo Web Library (OWL) for web development. It employs OWL concepts and principles in its POS system, with JavaScript code. To create a new custom button in the Odoo 17 POS screen, we need to create a new module which uses OWL Framework and integrate the JS and XML files for the buttons in the point_of_sale addon module.
  • 3. Enterprise Let’s create our custom module pos_custom_button. We will discuss about creating two different buttons, one in the Product screen and the other in the Payment Screen of POS. The basic structure of the module is as
  • 4. Enterprise To implement the task to create custom Popup buttons, we use the OWL concept by creating JS and XML files. In the manifest file of the module, we need to add these files as the POS assets of point_of_sale directory. ie, in the manifest add the code for assets key as: 'assets': { 'point_of_sale._assets_pos': [ 'pos_custom_button/static/src/js/*', 'pos_custom_button/static/src/js/PopUp/*', 'pos_custom_button/static/src/xml/pos_product_screen_button.xml', 'pos_custom_button/static/src/xml/pos_pop_up.xml', ] },
  • 5. Enterprise Navigate to the static/src/xml directory and create a new xml file. We need two xml files. ● Here, pos_pop_up.xml for designing the simple structure of the pop up window which is to be shown on clicking the button. ● pos_product_screen_button.xml which inherits the addon templates to show the custom buttons, one in the product screen and the other on the payment screen. Creating XML files
  • 6. Enterprise Using the <templates> tag, design the pop up in xml. pos_custom_button is the module name and CustomAlertPopup is the pop up name <t t-name="pos_custom_button.CustomAlertPopup" owl="1"> <div class="popup custom_popup"> <div class="modal-header justify-content-center"> <h2 class="modal-title"> <t t-esc="props.title"/></h2></div> <div class="modal-body custom-form-view"> <form><div class="col d-flex justify-content-between align-items- center p-3"> Pop up button clicked from POS </div> </form> </div> <div class="footer footer-flex modal-footer justify-content-end"> <div class="button cancel btn btn-lg btn-primary" t-on-click="cancel">Close <t t-esc="props.closePopup"/> </div> </div></div> </t>
  • 7. Enterprise It's important to specify the module and necessary screens in the JS file by utilizing /**@odoo-module **/ to define the module. This ensures that the JavaScript functionalities are properly associated with the Odoo module and its relevant screens. The js code which calls this pop up window template can be set as /** @odoo-module */ import { AbstractAwaitablePopup } from "@point_of_sale/app/popup/abstract_awaitable_popup"; /** * CustomAlertPopup component for displaying messages as an alert popup. * Inherits from AbstractAwaitablePopup. */ export class CustomAlertPopup extends AbstractAwaitablePopup { static template = "pos_custom_button.CustomAlertPopup"; }
  • 8. Enterprise After that, let’s create the custom buttons. The code for adding the template named CreateButton for the button in the Product screen is as: <t t-name="point_of_sale.CreateButton"> <button class="control-button btn btn-light rounded-0 fw-bolder" t-on-click="() => this.onClick()"> <i class="fa fa-pencil-square" role="img" aria-label="Custom Alert" title="Custom Alert"/> <span> </span> <span>Custom Button 1</span> </button> </t>
  • 10. Enterprise For the button in the Payment screen, here is the code for adding the template named CreateButton: <t t-name="pos_button.PaymentScreenButtons" t-inherit="point_of_sale.PaymentScreenButtons" t-inherit-mode="extension"> <xpath expr="//div[hasclass('payment-buttons')]" position="inside"> <button class="button button-partial-payment btn btn-light py-3 text-start rounded-0 border-bottom" t-on-click="onClick"> <i class="fa fa-money me-2"/>Custom Button 2 </button> </xpath> </t>
  • 12. Enterprise The JS file must be added after the button. For the first button created on the Product screen, add the following modules for extending the product screen js codes. /** @odoo-module */ import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { useService } from "@web/core/utils/hooks"; import { Component } from "@odoo/owl"; import { usePos } from "@point_of_sale/app/store/pos_hook"; import { CustomAlertPopup } from "@pos_custom_button/js/PopUp/popup_button";
  • 13. Enterprise Then, add the custom CreateButton component and add the onClick() method, export class CreateButton extends Component { static template = "point_of_sale.CreateButton"; /* Setup function to initialize the component.*/ setup() { this.pos = usePos(); this.popup = useService("popup"); } /* Click event handler for the create button.*/ async onClick() { this.popup.add(CustomAlertPopup) }} /* Add the OrderlineProduct CreateButton component to the control buttons in the ProductScreen.*/ ProductScreen.addControlButton({component: CreateButton,});
  • 14. Enterprise Now, just click on the Custom Button 1 on the Product screen. It’ll show the popup like
  • 15. Enterprise For the second button created on the Payment screen, add the js code. /**@odoo-module **/ import { _t } from "@web/core/l10n/translation"; import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen"; import { usePos } from "@point_of_sale/app/store/pos_hook"; import { CustomAlertPopup } from "@pos_custom_button/js/PopUp/popup_button"; import { patch } from "@web/core/utils/patch"; patch(PaymentScreen.prototype, { async onClick() { this.popup.add(CustomAlertPopup) }})
  • 16. Enterprise Then, just click on the Custom Button on the Payment screen. It’ll show the popup like
  • 17. Enterprise This is how custom buttons are incorporated into the Product and Payment screens in the point of sale interface. Additionally, you have the flexibility to position the button wherever desired by specifying the location and supplying the XPath. The assets files are integrated into the manifest files, and the button can be added via both JS and XML files.
  • 18. For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com