Hi all,
I’m trying to expose a custom field added on pos.order so that it can be used in the POS frontend OrderReceipt QWeb/OWL template in Odoo 18.
Goal
I want a custom field defined on pos.order to be available in the POS frontend, specifically in the order_receipt template.
What I have done
I extended the pos.order model and tried to load the field using _load_pos_data_fields method , as shown below:
pos_order.py
from odoo import models, fields, api
# pos_order.py
from odoo import models, fields, api
class PosOrder(models.Model):
_inherit = "pos.order"
custom_field = fields.Char()
@api.model
def _load_pos_data_fields(self, config_id):
fields = super()._load_pos_data_fields(config_id)
fields.append("custom_field")
return fields
Frontend error
After this change, the POS UI doesn't load at all, it crashes with the following error:
installHook.js:1 TypeError: Cannot read properties of undefined (reading 'filter') at get taxTotals (point_of_sale.assets_prod.min.js:8929:1016)
What I found so far
I found a couple of older forum posts and answers that suggest extending _loader_params_pos_order method on pos.session model
However, in Odoo 18, _loader_params_pos_order no longer exists, so those solutions are no longer applicable.
What is the correct way in Odoo 18 to load additional pos.order fields into the POS frontend?