The Point of Sale (POS) module in Odoo 18 has been extensively upgraded to offer a more robust and intuitive experience. The latest version introduces faster performance, real-time data synchronization, and an optimized interface designed to manage intricate operations with ease. The module also includes offline functionality, ensuring smooth transaction processing even when there is no internet connectivity. Furthermore, it integrates seamlessly with other Odoo applications such as inventory, accounting, and customer relationship management, creating a cohesive and efficient operational system.
Among the key enhancements is the simplified method for incorporating custom models and fields into the POS system. This capability enables businesses to customize the POS to address specific needs, such as specialized order types, additional customer data, or unique product details. These upgrades make the Odoo 18 POS module highly adaptable, catering to both retail and service-oriented industries. By focusing on flexibility and scalability, Odoo 18 continues to provide businesses with cutting-edge tools to streamline their operations and enhance overall efficiency.
Loading Models into POS
In previous versions of Odoo, loading custom models into the POS system required significant customization, involving multiple technical steps, including modifying the frontend and backend components. Odoo 18 simplifies this process by introducing the pos.load.mixin, which allows models to be directly loaded into the POS without the need for extensive modifications to the POS interface.
class CustomModel(models.Model):
"""Custom model to load inside the POS"""
_name = 'custom.model'
_description = 'custom model'
_inherit = ['pos.load.mixin']
name = fields.Char(string="Name")
In this code, we have created a model called CustomModel. The next step is to add this model into the POS system. To achieve this, it is required to inherit the pos.session model and override the _load_pos_data_models function within it. This function should be modified to return the name of the model that needs to be loaded into the POS.
# -*- coding: utf-8 -*-
from odoo import api, models
class PosSession(models.Model):
"""Inherit the pos.session to load the data of custom. model"""
_inherit = 'pos.session'
@api.model
def _load_pos_data_models(self, config_id):
"""load the data to the pos.config.models"""
data = super()._load_pos_data_models(config_id)
data += ['custom.model']
return data
Now, our customModel is loaded into the POS system. We can able to check this by console ‘this. models’ in your POS.
Loading fields
In Odoo18, it is really easy to add fields inside a model into the POS; for that, we must add a new function inside our custom model called _load_pos_data_fields and return the fields that we want to add inside the POS.
from odoo import api, fields, models
class CustomModel(models.Model):
"""Custom model to load inside the POS"""
_name = 'custom.model'
_description = 'custom model'
_inherit = ['pos.load.mixin']
name = fields.Char(string="Name")
@api.model
def _load_pos_data_fields(self, config_id):
return ['id', 'name']
Our fields are also loaded into the POS now.
This is how we can load the field and custom models into the POS system in Odoo 18.
Loading fields to an existing model
Loading fields into an existing model in Odoo 18 has been greatly simplified and streamlined. Odoo 18 introduces enhancements that make extending models and adding custom fields more efficient. As previously discussed, the _load_pos_data_fields function is used to load custom fields into the Point of Sale (POS). The same function can be utilized for this operation as well.
To load fields to an existing model we have to override the _load_pos_data_fields function
from odoo import api, fields, models
class CustomModel(models.Model):
"""Inherit the custom model to add a new field and add the field to the pos"""
_inherit = 'custom.model'
_description = 'custom model'
age = fields.Integer(string="Age")
@api.model
def _load_pos_data_fields(self, config_id):
data = super()._load_pos_data_fields(config_id)
data += ['age']
return data
This process demonstrates how fields and custom models can be effectively integrated into the Odoo POS system. By leveraging the updated capabilities of the POS module, businesses can customize their operations to align with specific requirements. This flexibility ensures that the POS system remains adaptable, scalable, and equipped to handle diverse business scenarios, ultimately enhancing overall efficiency and user satisfaction.
To read more about How to Load Models & Fields to POS in Odoo 17, refer to our blog How to Load Models & Fields to POS in Odoo 17.