ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
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

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

Dojo1.0_Tutorials
Dojo1.0_TutorialsDojo1.0_Tutorials
Dojo1.0_Tutorials
tutorialsruby
?
Dojo1.0_Tutorials
Dojo1.0_TutorialsDojo1.0_Tutorials
Dojo1.0_Tutorials
tutorialsruby
?
Devoxx 2014-webComponents
Devoxx 2014-webComponentsDevoxx 2014-webComponents
Devoxx 2014-webComponents
Cyril Balit
?
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
Celine George
?
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptx
Agusto Sipahutar
?
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
Celine George
?
How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17
Celine George
?
How to make a component and add it to systray in Odoo
How to make a component and add it to systray in OdooHow to make a component and add it to systray in Odoo
How to make a component and add it to systray in Odoo
Celine George
?
How to Create a Theme Module in Odoo 17 - Odoo 17 ºÝºÝߣs
How to Create a Theme Module in Odoo 17 - Odoo 17 ºÝºÝߣsHow to Create a Theme Module in Odoo 17 - Odoo 17 ºÝºÝߣs
How to Create a Theme Module in Odoo 17 - Odoo 17 ºÝºÝߣs
Celine George
?
How to Add New Item in CogMenu in Odoo 17
How to Add New Item in CogMenu in Odoo 17How to Add New Item in CogMenu in Odoo 17
How to Add New Item in CogMenu in Odoo 17
Celine George
?
Pinned Sites IE 9 Lightup
Pinned Sites IE 9 LightupPinned Sites IE 9 Lightup
Pinned Sites IE 9 Lightup
Wes Yanaga
?
How To Add Smart Buttons In Odoo 17 - Odoo ºÝºÝߣs
How To Add Smart Buttons In Odoo 17 - Odoo ºÝºÝߣsHow To Add Smart Buttons In Odoo 17 - Odoo ºÝºÝߣs
How To Add Smart Buttons In Odoo 17 - Odoo ºÝºÝߣs
Celine George
?
Web components with Angular
Web components with AngularWeb components with Angular
Web components with Angular
Ana Cidre
?
Report Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Report Actions In Odoo 17 - Odoo 17 ºÝºÝߣsReport Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Report Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Celine George
?
Visual Studio tool windows
Visual Studio tool windowsVisual Studio tool windows
Visual Studio tool windows
PVS-Studio
?
Solid angular
Solid angularSolid angular
Solid angular
Nir Kaufman
?
How To Add A Custom Button To The Chatter In Odoo 18 ?
How To Add A Custom Button To The Chatter In Odoo 18 ?How To Add A Custom Button To The Chatter In Odoo 18 ?
How To Add A Custom Button To The Chatter In Odoo 18 ?
CandidRoot Solutions Private Limited
?
How to Create a Popup in Odoo POS 17 - Odoo 17 ºÝºÝߣs
How to Create a Popup in Odoo POS 17 - Odoo 17 ºÝºÝߣsHow to Create a Popup in Odoo POS 17 - Odoo 17 ºÝºÝߣs
How to Create a Popup in Odoo POS 17 - Odoo 17 ºÝºÝߣs
Celine George
?
Client Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Client Actions In Odoo 17 - Odoo 17 ºÝºÝߣsClient Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Client Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Celine George
?
Module based
Module basedModule based
Module based
simpart simpart
?
Devoxx 2014-webComponents
Devoxx 2014-webComponentsDevoxx 2014-webComponents
Devoxx 2014-webComponents
Cyril Balit
?
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
Celine George
?
Tips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptxTips On Trick Odoo Add-On.pptx
Tips On Trick Odoo Add-On.pptx
Agusto Sipahutar
?
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
Celine George
?
How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17
Celine George
?
How to make a component and add it to systray in Odoo
How to make a component and add it to systray in OdooHow to make a component and add it to systray in Odoo
How to make a component and add it to systray in Odoo
Celine George
?
How to Create a Theme Module in Odoo 17 - Odoo 17 ºÝºÝߣs
How to Create a Theme Module in Odoo 17 - Odoo 17 ºÝºÝߣsHow to Create a Theme Module in Odoo 17 - Odoo 17 ºÝºÝߣs
How to Create a Theme Module in Odoo 17 - Odoo 17 ºÝºÝߣs
Celine George
?
How to Add New Item in CogMenu in Odoo 17
How to Add New Item in CogMenu in Odoo 17How to Add New Item in CogMenu in Odoo 17
How to Add New Item in CogMenu in Odoo 17
Celine George
?
Pinned Sites IE 9 Lightup
Pinned Sites IE 9 LightupPinned Sites IE 9 Lightup
Pinned Sites IE 9 Lightup
Wes Yanaga
?
How To Add Smart Buttons In Odoo 17 - Odoo ºÝºÝߣs
How To Add Smart Buttons In Odoo 17 - Odoo ºÝºÝߣsHow To Add Smart Buttons In Odoo 17 - Odoo ºÝºÝߣs
How To Add Smart Buttons In Odoo 17 - Odoo ºÝºÝߣs
Celine George
?
Web components with Angular
Web components with AngularWeb components with Angular
Web components with Angular
Ana Cidre
?
Report Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Report Actions In Odoo 17 - Odoo 17 ºÝºÝߣsReport Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Report Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Celine George
?
Visual Studio tool windows
Visual Studio tool windowsVisual Studio tool windows
Visual Studio tool windows
PVS-Studio
?
How to Create a Popup in Odoo POS 17 - Odoo 17 ºÝºÝߣs
How to Create a Popup in Odoo POS 17 - Odoo 17 ºÝºÝߣsHow to Create a Popup in Odoo POS 17 - Odoo 17 ºÝºÝߣs
How to Create a Popup in Odoo POS 17 - Odoo 17 ºÝºÝߣs
Celine George
?
Client Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Client Actions In Odoo 17 - Odoo 17 ºÝºÝߣsClient Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Client Actions In Odoo 17 - Odoo 17 ºÝºÝߣs
Celine George
?

More from Celine George (20)

Analysis of Conf File Parameters in the Odoo 18
Analysis of Conf File Parameters in the Odoo 18Analysis of Conf File Parameters in the Odoo 18
Analysis of Conf File Parameters in the Odoo 18
Celine George
?
Purchase Analysis in Odoo 17 - Odoo ºÝºÝߣs
Purchase Analysis in Odoo 17 - Odoo ºÝºÝߣsPurchase Analysis in Odoo 17 - Odoo ºÝºÝߣs
Purchase Analysis in Odoo 17 - Odoo ºÝºÝߣs
Celine George
?
Analysis of Conf File Parameters in Odoo 17
Analysis of Conf File Parameters in Odoo 17Analysis of Conf File Parameters in Odoo 17
Analysis of Conf File Parameters in Odoo 17
Celine George
?
How to Manage Check Out Process in Odoo 17 Website
How to Manage Check Out Process in Odoo 17 WebsiteHow to Manage Check Out Process in Odoo 17 Website
How to Manage Check Out Process in Odoo 17 Website
Celine George
?
Managing Online Signature and Payment with Odoo 17
Managing Online Signature and Payment with Odoo 17Managing Online Signature and Payment with Odoo 17
Managing Online Signature and Payment with Odoo 17
Celine George
?
Recruitment in the Odoo 17 - Odoo 17 ºÝºÝߣs
Recruitment in the Odoo 17 - Odoo 17 ºÝºÝߣsRecruitment in the Odoo 17 - Odoo 17 ºÝºÝߣs
Recruitment in the Odoo 17 - Odoo 17 ºÝºÝߣs
Celine George
?
How to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting AppHow to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting App
Celine George
?
How to Install Odoo 18 with Pycharm - Odoo 18 ºÝºÝߣs
How to Install Odoo 18 with Pycharm - Odoo 18 ºÝºÝߣsHow to Install Odoo 18 with Pycharm - Odoo 18 ºÝºÝߣs
How to Install Odoo 18 with Pycharm - Odoo 18 ºÝºÝߣs
Celine George
?
How to Manage Purchase Order Approval in Odoo 18
How to Manage Purchase Order Approval in Odoo 18How to Manage Purchase Order Approval in Odoo 18
How to Manage Purchase Order Approval in Odoo 18
Celine George
?
How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18
Celine George
?
How to Grant Discounts in Sale Order Lines in Odoo 18 Sales
How to Grant Discounts in Sale Order Lines in Odoo 18 SalesHow to Grant Discounts in Sale Order Lines in Odoo 18 Sales
How to Grant Discounts in Sale Order Lines in Odoo 18 Sales
Celine George
?
URLS and routing in odoo 18 - Odoo ºÝºÝߣs
URLS and routing in odoo 18 - Odoo ºÝºÝߣsURLS and routing in odoo 18 - Odoo ºÝºÝߣs
URLS and routing in odoo 18 - Odoo ºÝºÝߣs
Celine George
?
Comparing RFQ Lines for the best price in Odoo 17
Comparing RFQ Lines for the best price in Odoo 17Comparing RFQ Lines for the best price in Odoo 17
Comparing RFQ Lines for the best price in Odoo 17
Celine George
?
List View Attributes in Odoo 18 - Odoo ºÝºÝߣs
List View Attributes in Odoo 18 - Odoo ºÝºÝߣsList View Attributes in Odoo 18 - Odoo ºÝºÝߣs
List View Attributes in Odoo 18 - Odoo ºÝºÝߣs
Celine George
?
How to Set Default Terms and Conditions in Odoo 17 Accounting
How to Set Default Terms and Conditions in Odoo 17 AccountingHow to Set Default Terms and Conditions in Odoo 17 Accounting
How to Set Default Terms and Conditions in Odoo 17 Accounting
Celine George
?
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo SalesEnhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Celine George
?
What are the Views in Odoo 18 Purchase - Odoo ºÝºÝߣs
What are the Views in Odoo 18 Purchase - Odoo ºÝºÝߣsWhat are the Views in Odoo 18 Purchase - Odoo ºÝºÝߣs
What are the Views in Odoo 18 Purchase - Odoo ºÝºÝߣs
Celine George
?
Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18
Celine George
?
How to Add Custom Fields to Configuration Settings in Odoo 18
How to Add Custom Fields to  Configuration Settings in Odoo 18How to Add Custom Fields to  Configuration Settings in Odoo 18
How to Add Custom Fields to Configuration Settings in Odoo 18
Celine George
?
How to Manage Abandoned Cart in Odoo 17 Website
How to Manage Abandoned Cart in Odoo 17 WebsiteHow to Manage Abandoned Cart in Odoo 17 Website
How to Manage Abandoned Cart in Odoo 17 Website
Celine George
?
Analysis of Conf File Parameters in the Odoo 18
Analysis of Conf File Parameters in the Odoo 18Analysis of Conf File Parameters in the Odoo 18
Analysis of Conf File Parameters in the Odoo 18
Celine George
?
Purchase Analysis in Odoo 17 - Odoo ºÝºÝߣs
Purchase Analysis in Odoo 17 - Odoo ºÝºÝߣsPurchase Analysis in Odoo 17 - Odoo ºÝºÝߣs
Purchase Analysis in Odoo 17 - Odoo ºÝºÝߣs
Celine George
?
Analysis of Conf File Parameters in Odoo 17
Analysis of Conf File Parameters in Odoo 17Analysis of Conf File Parameters in Odoo 17
Analysis of Conf File Parameters in Odoo 17
Celine George
?
How to Manage Check Out Process in Odoo 17 Website
How to Manage Check Out Process in Odoo 17 WebsiteHow to Manage Check Out Process in Odoo 17 Website
How to Manage Check Out Process in Odoo 17 Website
Celine George
?
Managing Online Signature and Payment with Odoo 17
Managing Online Signature and Payment with Odoo 17Managing Online Signature and Payment with Odoo 17
Managing Online Signature and Payment with Odoo 17
Celine George
?
Recruitment in the Odoo 17 - Odoo 17 ºÝºÝߣs
Recruitment in the Odoo 17 - Odoo 17 ºÝºÝߣsRecruitment in the Odoo 17 - Odoo 17 ºÝºÝߣs
Recruitment in the Odoo 17 - Odoo 17 ºÝºÝߣs
Celine George
?
How to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting AppHow to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting App
Celine George
?
How to Install Odoo 18 with Pycharm - Odoo 18 ºÝºÝߣs
How to Install Odoo 18 with Pycharm - Odoo 18 ºÝºÝߣsHow to Install Odoo 18 with Pycharm - Odoo 18 ºÝºÝߣs
How to Install Odoo 18 with Pycharm - Odoo 18 ºÝºÝߣs
Celine George
?
How to Manage Purchase Order Approval in Odoo 18
How to Manage Purchase Order Approval in Odoo 18How to Manage Purchase Order Approval in Odoo 18
How to Manage Purchase Order Approval in Odoo 18
Celine George
?
How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18
Celine George
?
How to Grant Discounts in Sale Order Lines in Odoo 18 Sales
How to Grant Discounts in Sale Order Lines in Odoo 18 SalesHow to Grant Discounts in Sale Order Lines in Odoo 18 Sales
How to Grant Discounts in Sale Order Lines in Odoo 18 Sales
Celine George
?
URLS and routing in odoo 18 - Odoo ºÝºÝߣs
URLS and routing in odoo 18 - Odoo ºÝºÝߣsURLS and routing in odoo 18 - Odoo ºÝºÝߣs
URLS and routing in odoo 18 - Odoo ºÝºÝߣs
Celine George
?
Comparing RFQ Lines for the best price in Odoo 17
Comparing RFQ Lines for the best price in Odoo 17Comparing RFQ Lines for the best price in Odoo 17
Comparing RFQ Lines for the best price in Odoo 17
Celine George
?
List View Attributes in Odoo 18 - Odoo ºÝºÝߣs
List View Attributes in Odoo 18 - Odoo ºÝºÝߣsList View Attributes in Odoo 18 - Odoo ºÝºÝߣs
List View Attributes in Odoo 18 - Odoo ºÝºÝߣs
Celine George
?
How to Set Default Terms and Conditions in Odoo 17 Accounting
How to Set Default Terms and Conditions in Odoo 17 AccountingHow to Set Default Terms and Conditions in Odoo 17 Accounting
How to Set Default Terms and Conditions in Odoo 17 Accounting
Celine George
?
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo SalesEnhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Celine George
?
What are the Views in Odoo 18 Purchase - Odoo ºÝºÝߣs
What are the Views in Odoo 18 Purchase - Odoo ºÝºÝߣsWhat are the Views in Odoo 18 Purchase - Odoo ºÝºÝߣs
What are the Views in Odoo 18 Purchase - Odoo ºÝºÝߣs
Celine George
?
Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18
Celine George
?
How to Add Custom Fields to Configuration Settings in Odoo 18
How to Add Custom Fields to  Configuration Settings in Odoo 18How to Add Custom Fields to  Configuration Settings in Odoo 18
How to Add Custom Fields to Configuration Settings in Odoo 18
Celine George
?
How to Manage Abandoned Cart in Odoo 17 Website
How to Manage Abandoned Cart in Odoo 17 WebsiteHow to Manage Abandoned Cart in Odoo 17 Website
How to Manage Abandoned Cart in Odoo 17 Website
Celine George
?

Recently uploaded (20)

? Marketing is Everything in the Beauty Business! ??? Talent gets you in the ...
? Marketing is Everything in the Beauty Business! ??? Talent gets you in the ...? Marketing is Everything in the Beauty Business! ??? Talent gets you in the ...
? Marketing is Everything in the Beauty Business! ??? Talent gets you in the ...
coreylewis960
?
Unit No 4- Chemotherapy of Malignancy.pptx
Unit No  4- Chemotherapy of Malignancy.pptxUnit No  4- Chemotherapy of Malignancy.pptx
Unit No 4- Chemotherapy of Malignancy.pptx
Ashish Umale
?
Design approaches and ethical challenges in Artificial Intelligence tools for...
Design approaches and ethical challenges in Artificial Intelligence tools for...Design approaches and ethical challenges in Artificial Intelligence tools for...
Design approaches and ethical challenges in Artificial Intelligence tools for...
Yannis
?
Unit1 Inroduction to Internal Combustion Engines
Unit1  Inroduction to Internal Combustion EnginesUnit1  Inroduction to Internal Combustion Engines
Unit1 Inroduction to Internal Combustion Engines
NileshKumbhar21
?
General Quiz at ChakraView 2025 | Amlan Sarkar | Ashoka Univeristy | Prelims ...
General Quiz at ChakraView 2025 | Amlan Sarkar | Ashoka Univeristy | Prelims ...General Quiz at ChakraView 2025 | Amlan Sarkar | Ashoka Univeristy | Prelims ...
General Quiz at ChakraView 2025 | Amlan Sarkar | Ashoka Univeristy | Prelims ...
Amlan Sarkar
?
MIPLM subject matter expert Sascha Kamhuber
MIPLM subject matter expert Sascha KamhuberMIPLM subject matter expert Sascha Kamhuber
MIPLM subject matter expert Sascha Kamhuber
MIPLM
?
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdf
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdfBerry_Kanisha_BAS_PB1_202503 (2) (2).pdf
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdf
KanishaBerry
?
MIPLM subject matter expert Nicos Raftis
MIPLM subject matter expert Nicos RaftisMIPLM subject matter expert Nicos Raftis
MIPLM subject matter expert Nicos Raftis
MIPLM
?
UTI Quinolones by Mrs. Manjushri Dabhade
UTI Quinolones by Mrs. Manjushri DabhadeUTI Quinolones by Mrs. Manjushri Dabhade
UTI Quinolones by Mrs. Manjushri Dabhade
Dabhade madam Dabhade
?
Knownsense 2025 Finals-U-25 General Quiz.pdf
Knownsense 2025 Finals-U-25 General Quiz.pdfKnownsense 2025 Finals-U-25 General Quiz.pdf
Knownsense 2025 Finals-U-25 General Quiz.pdf
Pragya - UEM Kolkata Quiz Club
?
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
home
?
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
Amlan Sarkar
?
Digital Electronics: Fundamentals of Combinational Circuits
Digital Electronics: Fundamentals of Combinational CircuitsDigital Electronics: Fundamentals of Combinational Circuits
Digital Electronics: Fundamentals of Combinational Circuits
GS Virdi
?
Knownsense 2025 prelims- U-25 General Quiz.pdf
Knownsense 2025 prelims- U-25 General Quiz.pdfKnownsense 2025 prelims- U-25 General Quiz.pdf
Knownsense 2025 prelims- U-25 General Quiz.pdf
Pragya - UEM Kolkata Quiz Club
?
EDL 290F Week 5 - Facing Headwinds and Hairpin Turns (2025).pdf
EDL 290F Week 5  - Facing Headwinds and Hairpin Turns (2025).pdfEDL 290F Week 5  - Facing Headwinds and Hairpin Turns (2025).pdf
EDL 290F Week 5 - Facing Headwinds and Hairpin Turns (2025).pdf
Liz Walsh-Trevino
?
Unit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition EnginesUnit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition Engines
NileshKumbhar21
?
MIPLM subject matter expert Dr Robert Klinski
MIPLM subject matter expert Dr Robert KlinskiMIPLM subject matter expert Dr Robert Klinski
MIPLM subject matter expert Dr Robert Klinski
MIPLM
?
Antifungal agents by Mrs. Manjushri Dabhade
Antifungal agents by Mrs. Manjushri DabhadeAntifungal agents by Mrs. Manjushri Dabhade
Antifungal agents by Mrs. Manjushri Dabhade
Dabhade madam Dabhade
?
Gold Spot Dairy Store Jordan Minnesota 55352
Gold Spot Dairy Store Jordan Minnesota 55352Gold Spot Dairy Store Jordan Minnesota 55352
Gold Spot Dairy Store Jordan Minnesota 55352
Forklift Trucks in Minnesota
?
? Marketing is Everything in the Beauty Business! ??? Talent gets you in the ...
? Marketing is Everything in the Beauty Business! ??? Talent gets you in the ...? Marketing is Everything in the Beauty Business! ??? Talent gets you in the ...
? Marketing is Everything in the Beauty Business! ??? Talent gets you in the ...
coreylewis960
?
Unit No 4- Chemotherapy of Malignancy.pptx
Unit No  4- Chemotherapy of Malignancy.pptxUnit No  4- Chemotherapy of Malignancy.pptx
Unit No 4- Chemotherapy of Malignancy.pptx
Ashish Umale
?
Design approaches and ethical challenges in Artificial Intelligence tools for...
Design approaches and ethical challenges in Artificial Intelligence tools for...Design approaches and ethical challenges in Artificial Intelligence tools for...
Design approaches and ethical challenges in Artificial Intelligence tools for...
Yannis
?
Unit1 Inroduction to Internal Combustion Engines
Unit1  Inroduction to Internal Combustion EnginesUnit1  Inroduction to Internal Combustion Engines
Unit1 Inroduction to Internal Combustion Engines
NileshKumbhar21
?
General Quiz at ChakraView 2025 | Amlan Sarkar | Ashoka Univeristy | Prelims ...
General Quiz at ChakraView 2025 | Amlan Sarkar | Ashoka Univeristy | Prelims ...General Quiz at ChakraView 2025 | Amlan Sarkar | Ashoka Univeristy | Prelims ...
General Quiz at ChakraView 2025 | Amlan Sarkar | Ashoka Univeristy | Prelims ...
Amlan Sarkar
?
MIPLM subject matter expert Sascha Kamhuber
MIPLM subject matter expert Sascha KamhuberMIPLM subject matter expert Sascha Kamhuber
MIPLM subject matter expert Sascha Kamhuber
MIPLM
?
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdf
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdfBerry_Kanisha_BAS_PB1_202503 (2) (2).pdf
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdf
KanishaBerry
?
MIPLM subject matter expert Nicos Raftis
MIPLM subject matter expert Nicos RaftisMIPLM subject matter expert Nicos Raftis
MIPLM subject matter expert Nicos Raftis
MIPLM
?
UTI Quinolones by Mrs. Manjushri Dabhade
UTI Quinolones by Mrs. Manjushri DabhadeUTI Quinolones by Mrs. Manjushri Dabhade
UTI Quinolones by Mrs. Manjushri Dabhade
Dabhade madam Dabhade
?
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
home
?
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
Amlan Sarkar
?
Digital Electronics: Fundamentals of Combinational Circuits
Digital Electronics: Fundamentals of Combinational CircuitsDigital Electronics: Fundamentals of Combinational Circuits
Digital Electronics: Fundamentals of Combinational Circuits
GS Virdi
?
EDL 290F Week 5 - Facing Headwinds and Hairpin Turns (2025).pdf
EDL 290F Week 5  - Facing Headwinds and Hairpin Turns (2025).pdfEDL 290F Week 5  - Facing Headwinds and Hairpin Turns (2025).pdf
EDL 290F Week 5 - Facing Headwinds and Hairpin Turns (2025).pdf
Liz Walsh-Trevino
?
Unit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition EnginesUnit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition Engines
NileshKumbhar21
?
MIPLM subject matter expert Dr Robert Klinski
MIPLM subject matter expert Dr Robert KlinskiMIPLM subject matter expert Dr Robert Klinski
MIPLM subject matter expert Dr Robert Klinski
MIPLM
?
Antifungal agents by Mrs. Manjushri Dabhade
Antifungal agents by Mrs. Manjushri DabhadeAntifungal agents by Mrs. Manjushri Dabhade
Antifungal agents by Mrs. Manjushri Dabhade
Dabhade madam Dabhade
?

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