The Point of Sale (POS) system in Odoo 18 is designed to be fast, user-friendly, and highly customizable. One of the most critical features for any retail system is product search, which allows the cashier to quickly locate products by typing keywords.
However, the default product search in Odoo POS may only match product names or specific fields. But every business is different; some might want to search by internal reference, category, custom attributes, or even brand names.
We'll dive deep into the frontend architecture of Odoo POS, understand how product search works, and explore how to override and extend this behavior using OWL, Odoo’s reactive web framework.
In Odoo 18's POS, product search primarily happens through the ProductScreen component. The key method we'll focus on is getProductsBySearchWord(), which is responsible for filtering products based on user input in the search bar.
We will use the patch() utility provided by OWL to override the getProductsBySearchWord() method of the ProductScreen component in POS. This is the method responsible for returning a filtered list of products when a user types something in the POS search bar.
The patch() utility from @web/core/utils/patch is the recommended way to modify existing class behavior in Odoo 18. Here's the basic structure:
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { patch } from "@web/core/utils/patch";
patch(ProductScreen.prototype, {
getProductsBySearchWord(searchWord) {
//Custom logic },
});For example, searching for the product by the barcode
/** @odoo-module **/
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { patch } from "@web/core/utils/patch";
patch(ProductScreen.prototype, {
getProductsBySearchWord(searchWord) {
const word = searchWord.toLowerCase();
return this.products.filter((product) => {
const barcode = product.barcode || "";
const barcodeMatch = barcode.toLowerCase().includes(word);
return barcodeMatch ;
});},
});
Customizing the product search functionality in Odoo 18 POS is not just a technical enhancement—it's a practical improvement that directly impacts cashier efficiency, customer satisfaction, and overall business performance.
To read more about How to Override a Component in the Odoo 19 POS, refer to our blog How to Override a Component in the Odoo 19 POS.