How to Transfer POS Session Data into POS Orders in Odoo 18

Discover how to link POS session data with POS orders efficiently in Odoo 18.

Jul 2, 2025 - 13:37
Jul 2, 2025 - 13:42
 2
How to Transfer POS Session Data into POS Orders in Odoo 18

Odoo 18 offers a flexible and powerful Point of Sale (POS) module that businesses can customize to fit their specific needs. As an ERP consultant, one common task is helping businesses move important data from the POS front-end to the backend orders. For example, you might want to save customer feedback, promotional notes, or special instructions linked to each sale. In this blog, we’ll guide you on how to load POS session data, like customer suggestions, into POS orders in Odoo 18.


Add a Custom Field to the POS Order Model

First, we need to create a custom field in the pos.order model to store the customer’s suggestion:

from odoo import fields, models
class PosOrder(models.Model):
    _inherit = 'pos.order'
    suggestion = fields.Char(
        string='Customer Suggestion',
        readonly=True,
        help='Customer suggestion can be seen here'
    )

This field will store any feedback the customer gives during the POS session.


Show the Field in the POS Order Form

Next, we’ll update the POS order form view to display the suggestion field in the backend:



    
        pos.order.form.view
        pos.order
        
        
            
                
                    
                
            
        
    

Now, this field will appear under the Extra tab in the POS order form.


Add Customer Suggestion Button to POS Screen

To collect customer suggestions, we’ll add a new button on the POS payment screen:



This button lets the cashier open a popup to collect suggestions.


Define What Happens When Button Is Clicked

Let’s write the code that shows a popup and saves what the customer says:

/** @odoo-module **/
import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen";
import { patch } from "@web/core/utils/patch";
import { _t } from "@web/core/l10n/translation";
import { TextInputPopup } from "@point_of_sale/app/utils/input_popups/text_input_popup";
import { makeAwaitable } from "@point_of_sale/app/store/make_awaitable_dialog";

patch(PaymentScreen.prototype, {
    async customer_suggestion() {
        const selectedOrder = this.pos.get_order();
        if (!selectedOrder) {
            console.warn("No active order found.");
            return;
        }
        const existingSuggestion = selectedOrder.suggestion || "";
        const payload = await makeAwaitable(this.dialog, TextInputPopup, {
            title: _t("Add Customer Suggestion"),
            rows: 4,
            startingValue: existingSuggestion,
        });
        if (payload && typeof payload === "string") {
            selectedOrder.set_customer_suggestion(payload);
        }
        return { confirmed: typeof payload === "string", inputSuggestion: payload };
    }
});

When the button is clicked, a popup opens so the cashier can type in customer feedback.


Transfer Session Data to Backend POS Order

Finally, we make sure the suggestion is saved when the order is sent to the backend:

/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import { PosOrder } from "@point_of_sale/app/models/pos_order";

patch(PosOrder.prototype, {
    setup(vals) {
        super.setup(vals);
        this.suggestion = vals.suggestion || false;
    },
    set_customer_suggestion(suggestion) {
        this.suggestion = suggestion;
    },
});

This ensures suggestions entered during the POS session get stored in the POS order in the backend.


Conclusion

By following these steps, you can successfully capture and save session-based data, like customer suggestions, from the POS front-end into backend POS orders in Odoo 18. This small but powerful customization can improve customer service, enhance reporting, and help businesses gain valuable insights. You can also extend this method to collect other session details, such as delivery notes or discount approvals.


Booking an implementation consultant today.