The POS in Odoo 19 functions faster than before while maintaining its features. It assists businesses in managing their tasks smoothly without delays or issues by processing data swiftly and remaining reliable behind the scenes.
The true power of Odoo 19, for developers, lies in the ease of integrating custom models and fields into the POS. Tasks that once demanded frontend modifications now adhere to a backend-focused approach that maintains the existing framework and operates much more effectively.
Odoo 19 provides an approach to extend current models, incorporating additional data and modifying the POS to meet specific business requirements. Pos.load.mixin guarantees that customisation is dependable, uniform and prepared for real-world application.
Loading Models into POS
In Odoo 19, models continue to be loaded into the POS through a method. To have the POS fetch a custom model, you need to inherit pos.load.mixin. Doing this informs Odoo that your model could be included in the POS data bundle when the session loads. This approach avoids JS changes, widget overrides or any frontend patching.
To expand the pos.session model once it has been established, you need to override _load_pos_data_models. Odoo acts as a checklist by collecting all model names provided here and loading their data during POS startup.
# -*- coding: utf-8 -*-
from odoo import api, fields, models
class CustomModel(models.Model):
"""Custom model made available inside the POS."""
_name = 'custom.model'
_description = 'Custom Model'
_inherit = ['pos.load.mixin']
name = fields.Char(
string="Name",
help="Name of the custom record loaded into the POS."
)
# -*- coding: utf-8 -*-
class PosSession(models.Model):
"""Extend POS session to load custom models."""
_inherit = 'pos.session'
@api.model
def _load_pos_data_models(self, config_id):
"""Return models to be loaded into the POS session."""
data = super()._load_pos_data_models(config_id)
data += ['custom.model']
return data
Your model is then integrated into the POS environment. The browser console is available for inspection.
Loading Fields into POS
Loading the model is inadequate to retrieve its fields. Odoo maintains POS efficiency by loading the requested data. To define the fields, you override _load_pos_data_fields, within your model. This function returns a list of field names that need to be delivered to the POS.
# -*- coding: utf-8 -*-
from odoo import api, fields, models
class CustomModel(models.Model):
"""Custom model made available inside the POS."""
_name = 'custom.model'
_description = 'Custom Model'
_inherit = ['pos.load.mixin']
name = fields.Char(
string="Name",
help="Name of the custom record loaded into the POS."
)
@api.model
def _load_pos_data_fields(self, config_id):
"""Return fields to be loaded into the POS."""
return ['id', 'name']
By choosing only the fields that are required, you can keep your POS session loading quickly and avoid data transfers.
Adding Fields to Existing Models
In cases, creating a new model is unnecessary. Frequently, adding internal flags, product information or customer attributes to a pre-existing model suffices. With Odoo 19, this process is straightforward: Override _load_pos_data_fields include the field and inherit the model.
# -*- coding: utf-8 -*-
from odoo import api, fields, models
class CustomModel(models.Model):
"""
Extends the custom.model to include the 'age' field and ensures
that this field is sent to the POS during session loading.
"""
_inherit = 'custom.model'
age = fields.Integer(
string="Age",
help="Indicates the age value that will be available in the POS."
)
@api.model
def _load_pos_data_fields(self, config_id):
"""
Adds the 'age' field to the list of fields loaded into the POS.
"""
data = super()._load_pos_data_fields(config_id)
data += ['age']
return data
The POS subsequently incorporates your added field alongside the existing ones. This approach guarantees that your changes remain compatible, updates maintain extra logic organised within the backend and prevents the need to rewrite existing frameworks.
Conclusion
Odoo 19 simplifies POS customisation by allowing developers to load m*//dels and fields via backend extensions, eliminating the need for extensive frontend modifications. With pos.load.mixin the platform provides a consistent method to incorporate the data essential for your POS.
Whether you're adding a new model or enhancing an existing one, the process is still simple and helpful. This keeps the POS quick, adaptable, and ready to support real business workflows while maintaining the solid foundation Odoo has always had.
To read more about How to Load Models & Fields to POS in Odoo 18, refer to our blog, How to Load Models & Fields to POS in Odoo 18.
FAQ
1. Is it necessary to implement frontend changes to load models into the POS?
No. Because Odoo 19 fully loads models through the backend, utilising pos.load.mixin there is no need for JavaScript overrides.
2. Do all the fields in the model load automatically?
No. The POS will display the fields you provide in _load_pos_data_fields. This approach ensures efficiency is preserved.
3. Is it possible to add fields to POS by incorporating them into existing models?
Indeed. Extend _load_pos_data_fields to incorporate your fields after inheriting the model.
4. Are these techniques effective without an internet connection?
Absolutely. The information remains available offline until synchronisation when the POS session retrieves it.
5. Can multiple custom models be loaded into POS?
Certainly. Just input the names of all models in _load_pos_data_models. Odoo will initialise them at the session’s start.