Enable Dark Mode!
how-to-customize-pos-receipts-in-the-odoo-17.jpg
By: Ayana KP

How to Customize POS Receipts in the Odoo 17

Technical Odoo 17

PoS receipts serve as tangible touchpoints between your business and your customers. By customizing these receipts, you can convey professionalism, reinforce brand values, and provide relevant information to your customers. Whether it's adding a logo, including promotional messages, or tailoring the layout, customization allows you to create a memorable and cohesive brand experience.

Let's delve into the detailed process of customizing Odoo POS receipts. But before we dive into customization, let's take a moment to review the default POS receipts as they appear in Odoo 17.

In the default view, we observe that it presents only fundamental details concerning the current order, providing room for customization tailored to our specific requirements.

To initiate the customization of receipts, the initial step involves creating an XML file within the Static ? Src ? Xml directory.

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
   <t t-name="custom_pos_receipt.OrderReceipt"
      t-inherit="point_of_sale.ReceiptHeader" t-inherit-mode="extension">
        <xpath expr="//div[hasclass('pos-receipt-contact')]" position="inside">
           <t t-if="props.data.partner.name" >
               <div>Client:
               <t t-esc='props.data.partner.name'/>
                               </div>
           </t>
       </xpath>
   </t>
</templates>

This XML snippet modifies a Point of Sale (PoS) receipt template to include the client's name below the "Client:" label. It employs XPath to insert the custom content at a specific location within the parent template. However, prior to this customization, it's necessary to load the partner's name into the header data. To achieve this, we create a JavaScript file and incorporate the following code:

/** @odoo-module */
import { Order } from "@point_of_sale/app/store/models";
import { patch } from "@web/core/utils/patch";
patch(Order.prototype, {
   export_for_printing() {
       const result = super.export_for_printing(...arguments);
       if (this.get_partner()) {
           result.headerData.partner = this.get_partner();
       }
       return result;
   },
});

 It imports the "Order" model and the "patch" function from the respective modules. The code extends the functionality of the "export_for_printing" method of the Order model by adding additional data to the header section of the receipt. Specifically, it checks if there is a partner associated with the order and if so, it adds the partner's information to the header data. This enhancement allows for more comprehensive printing of receipts in PoS transactions, providing additional context, such as customer details when available. Finally, the patched method is returned for further use within the application. Subsequently, we incorporate all files in the "__manifest__.py" file.

'assets': {
   'point_of_sale._assets_pos': [
       Module_name/static/src/**/*',
   ],
},

How to Customize POS Receipts in the Odoo 17-cybrosys

In certain scenarios, it's necessary to load custom fields that have been created. In such cases, you can achieve this through Python code. For instance, if you've created a custom field in the product_product model, the corresponding Python code would resemble the following:

class PosSessions(models.Model):
   _inherit = 'pos.session'
   def _loader_params_product_product(self):
       result = super()._loader_params_product_product()
       result['search_params']['fields'].append('your_custom_field')
       return result

Customizing PoS receipts in Odoo 17 offers businesses a powerful tool for reinforcing brand identity and delivering a memorable customer experience. By leveraging the customization capabilities of Odoo 17, businesses can create personalized receipt templates that reflect their unique brand values and resonate with customers.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message