Hello community, does anyone knows if Odoo has a way to use QR codes in PDF documents? I need to use generate some information in my QR code related to data in the PDF.
This question has been flagged
Odoo allows the creation of a QR-type image that is fed with information from the database (dynamic fields), similar to how we fill a PDF document with various dynamic fields. To achieve this, we will use the Studio application and the PDF editor (specifically the “QWeb”). Follow these steps:
- Access the PDF report you want to edit using Studio (for this example, we will use a new document).


- Once the new document or the document to edit is ready, use the "</> Edit Sources" function.

- Now we will insert code to create the QR image we need:

<img t-att-src="'/report/barcode/QR/%s' % (doc.partner_id.name)"/>
This code is represented as follows:
- With the code written, you will be able to see the QR code information, but not in the desired format. To fix this, use the following extension:
<img t-att-src="'/report/barcode/QR/%s' % (doc.partner_id.name)" style="width:120px;height:120px"/>

The result of the code is the next one:
If you need to include more information, you must use connectors within the parentheses of the code.
- Use the connector "+" to add more fields.
- You can keep adding as many fields as needed.


- When scanned, the result will be:

- If you want the information to appear separated, you can include separators within the code to improve readability.

- Quotation marks allow you to define spaces, separators, or text characters. The result will look like this:


- Once all elements and fields have been configured, you can finish editing the document, and it will update according to the information entered in the system.
BARCODES
For barcodes, the process is similar. However, keep in mind:
- Barcodes can only store a single alphanumeric value (as in the Inventory application).
To insert a barcode into a PDF document, follow the same steps but use the following code:
<div t-field="doc.name" t-options="{'widget': 'barcode', 'width': 400, 'height': 100}"/>

The final result will look like this:

GENERAL RECOMMENDATIONS
Next, here are some recommendations to take in consideration about using this tipe of functions in Odoo:
The recommended minimal size to use is:
- QR: 2x2 cm [Ideal= 3 - 4cm]
- Barcode: height = 1 cm [quiet zone is mandatory]
- When positioning the QR or Barcode is important to avoid borders of the document and fold areas (if printed).
- Try to keep a good contrast to help the lecture of the code (white background and solid black text).
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up| Related Posts | Replies | Views | Activity | |
|---|---|---|---|---|
|
|
0
Sep 21
|
4760 | ||
|
|
1
May 18
|
5775 | ||
|
|
2
Jan 17
|
8714 | ||
|
|
3
Mar 15
|
9627 | ||
|
|
2
Oct 24
|
4278 |

