Skip to Content

Add Barcode to POS Receipt in Odoo 19 🚀 (No Python, Frontend Only!)

30 December 2025 by
Add Barcode to POS Receipt in Odoo 19 🚀 (No Python, Frontend Only!)
Odooistic
| No comments yet


Add a Barcode to Odoo 19 POS Receipts — Frontend Only, Upgrade Safe

Add a scannable order-level barcode to printed POS receipts in Odoo 19 without touching any Python code. The approach uses only POS assets: a small module that injects a JavaScript patch, a QWeb template extension, and a bit of CSS. It is lightweight, upgrade safe, and uses Odoo's built-in barcode generator so no external barcode libraries are required.

Why this approach

  • No Python models — everything runs in the POS frontend.
  • Upgrade safe — QWeb inheritance and JS patches instead of core overrides.
  • Server-generated barcodes — uses Odoo's /report/barcode route for reliable, printable images.
  • Printer friendly — CSS tuned for thermal receipt widths and scanners.

High-level steps

  1. Create a minimal custom module folder.
  2. Add a manifest that declares a dependency on point_of_sale and registers POS assets.
  3. Patch the POS Order model in a JavaScript asset to compute a barcode value and build a barcode image URL.
  4. Extend the POS receipt QWeb template to inject the barcode image and its human-readable value.
  5. Style the barcode block with CSS so it prints and scans well.
  6. Install the module, restart Odoo, and test a receipt.

Module layout

Create a small module: for example, pos_receipt_custom_19. The minimal structure:

  • __manifest__.py — declare depends on point_of_sale and register assets under assets_pos.
  • static/src/js/pos_order_barcode.js — patch the POS Order to expose barcode properties.
  • static/src/xml/pos_receipt_ext.xml — QWeb template extension to insert the barcode into the receipt.
  • static/src/css/pos_receipt_barcode.css — styling for the barcode block.

Manifest essentials

The manifest must include the dependency on point_of_sale so Odoo loads the assets into the POS environment. Use the assets_pos key to list the JS, XML, and CSS files. Anything listed there will be injected into the POS frontend when a session starts.

Patch the POS Order with JavaScript

The JS asset extends the POS Order model using Odoo's patch utility rather than overwriting classes. This keeps your customization upgrade safe and compatible with other modules.

Key responsibilities of the patch:

  • Provide a computed getter for a stable barcode value. If the order has a finalized name (for example POS/23/000123) use that. If not yet finalized, fall back to the POS session UID to ensure uniqueness.
  • Build the barcode image URL using Odoo's built-in barcode route. Read the barcode value, choose a barcode type (code128 is a good default), and assemble a URL that points to the server route that generates the barcode image.
  • Return an empty string when there is no value so the receipt template can conditionally skip rendering.

Practical notes when building the URL:

  • Use the current Odoo base URL (session.url or equivalent) and ensure you remove any trailing slash so the generated route is correct in cloud and on-premises installations.
  • Include query parameters for type (for example code128), value, and humanreadable=1 to print the readable text beneath the bars.

Extend the QWeb receipt template

Do not replace the whole receipt. Create a QWeb template with extension mode and inject a new block at the appropriate XPath (commonly just before the receipt footer). The injected block should:

  • Conditionally render only when the patched order exposes a non-empty barcode URL.
  • Render an img-style element pointing to the computed barcode URL so the image is printed on the receipt.
  • Render the human-readable value under the barcode so staff can manually look up orders if scanning fails.

CSS: printer-friendly and scannable

Add a small CSS file that:

  • Centers the barcode block for readability and scanner alignment.
  • Sets the barcode image to width: 100% with a sensible max-width (for example 320px) so it adapts to different receipt widths but remains scannable.
  • Gives the barcode a fixed height and object-fit: contain so it prints consistently without being stretched or cropped.
  • Renders the human-readable text in a smaller, readable font with slight letter spacing.

Install and test

  1. Place the module directory under your Odoo addons path.
  2. Restart the Odoo service so new assets are picked up by the bundler.
  3. Update the apps list and install the new module from Apps.
  4. Open the POS, create a sale, validate payment, and print the receipt. You should see the barcode image and the readable code beneath it.

Common customizations and tips

  • Barcode type override: Expose a POS configuration option if you need support for different barcode symbologies.
  • Location on the receipt: Change the XPath insertion point to move the barcode above totals, after totals, or in the footer.
  • Alternate values: Encode a custom token or include additional contextual information if you need the barcode to represent something other than the order reference.
  • Error handling: Gracefully skip rendering when the barcode value is missing or when the generated URL is invalid.

Use cases

  • Fast returns and refunds at the counter by scanning the receipt barcode to pull the original order.
  • Warranty or service workflows where an order-level reference is needed.
  • Quick order lookup during busy retail operations.

Resources

Example module source available at: https://github.com/ffaemy/my_odoo_modules (look for the pos_barcode folder)

For professional Odoo customization or training contact: contact@odooistic.co.uk

Summary

Adding a barcode to Odoo 19 POS receipts can be done cleanly and safely with frontend-only changes: a small module that registers POS assets, patches the POS Order model to expose a barcode value and URL, extends the receipt template with QWeb, and styles the result with CSS. The result is a scannable, printer-friendly barcode on every receipt to speed returns, improve lookup workflows, and make day-to-day POS operations smoother.

Sign in to leave a comment