Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
187 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Mejor respuesta

Hello Dan,



It's tricky to add barcodes directly in Odoo Online Studio because it doesn't support custom code. However, you can leverage Odoo's built-in barcode functionality through a workaround:


  First, ensure the field you want to represent as a barcode (e.g., product ID or serial number) is correctly populated in your Odoo database.

  Next, in Odoo Studio, add a new "HTML" field to your report.

  Within the HTML field, use Odoo's QWeb templating engine to generate the barcode. The basic syntax is: <img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('Code128', o.your_field_name, 600, 100)" style="width:300px;height:50px;"/>. Replace o.your_field_name with the actual field name.

  Adjust the type (e.g., Code128, EAN13), width, and height parameters to suit your needs. The style attribute controls the display size.

  Save your changes and test the report to see the barcode generated from the specified field.


For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html

Avatar
Descartar