Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
251 Tampilan

I'm trying to create my own barcoded labels within Odoo 18.4 Online Studio. I've taken a look at some of the other solutions that used barcodes on their reports, but it's not really clear how the barcodes get added to the report.


I've been searching online, but everything I've found so far involves custom code, and unfortunately the Odoo online system doesn't allow for custom code.

Avatar
Buang
Jawaban Terbai

Hello Dan Cliff,

 

In Odoo Online (Studio environment), you don't have access to custom Python modules, but you can still add barcodes to your reports using QWeb XML directly inside Studio. The barcode images are generated dynamically by Odoo's built-in /report/barcode/ controller.

 

Here is how you can achieve it step by step:

  1. Open the Report in Studio
    • Go to the app and open the report you want to modify (eg, Sales Order ).
    • Click the Studio (wrench) icon to edit the layout.

  1. Insert a Field Area
    • Add a field, column, or block in the place where you want your barcode to appear.
    • This will create a space in the layout.

  1. Edit Report Sources (XML)
    • In Studio, click EDIT SOURCES .
    • This will open the underlying QWeb XML code.
  2. Insert the Barcode Snippet
    Add the following XML code where you want the barcode to display:

    """"""""""""""""""""""""""""""""
    <div>
    <div class="col-5">
    <span style="margin-left:-60px;">
    <img t-if="doc.client_order_ref"style="width:400px;height:70px;"t-att-src="'/report/barcode/?barcode_type=%s&value=%s&width=%s&height=%s' % ('EAN13', doc.client_order_ref, 265, 80)"/>
    </span>    
    <div style="margin-left:100px" t-field="doc.client_order_ref"/>
    </div>
    </div>    
    """""""""""""""""""""""""""""""""""""

 

  • Replace doc.client_order_ref with the field you want to encode as a barcode.
    Examples:
    • Sales Order Number → doc.name
    • Customer Reference → doc.client_order_ref
    • Invoice Number → doc.move_name
  1. Save and Preview
    • Click Save in Studio.
    • Preview or print the report.
    • You will now see both the reference text and a scannable barcode.



If you have any questions, feel free to reach out to us.

Hope this helps!


Thanks & Regards,

Email : odoo@aktivsoftware.com


Avatar
Buang
Penulis

Thank you for that code, I've been trying it but keep getting an "error while rendering".

This is the full XML code block for my report.

<data>
<xpath expr="/t[@t-name='studio_report_document']/div/div" position="replace" meta-class="oe_structure"/>
<xpath expr="/t[@t-name='studio_report_document']/div" position="inside" meta-class="page">
<div class="oe_structure">
<br/>
</div>

<h2 class="oe_structure">
<span t-field="doc.name"/>
</h2>

<p>
<br/>
</p>
<br/>

<div>
<div class="col-5">
<span style="margin-left:-60px;">
<img t-if="doc.barcode"
style="width:400px;height:70px;"
t-att-src="'/report/barcode/?barcode_type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN13', doc.barcode, 265, 80)"/>
</span>
<div style="margin-left:100px;">
<span t-field="doc.client_order_ref"/>
</div>
</div>
</div>
</xpath>
</data>

Penulis

Ignore my last comment - I was able to get it working, was finally able to find a copy of the working xml code from a test database and could copy and paste it over.