Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

The barcode is not displayed in Qweb report (Odoo)

Subscribe

Get notified when there's activity on this post

This question has been flagged
odooqweb-report
3 Replies
22477 Views
Avatar
Adnier Rosello

I have a Qweb report that should display a barcode, but what is shown is the blank where it should be the barcode, below the full code of the report, and the displayed error when the controller /report/barcode is called, any idea?


report definition:

<report
id="roll_label_report"
string="Product label"
model="mrp.production.product"
report_type="qweb-pdf"
file="mrp.product_label_document"
name="mrp.product_label_document" />

report template

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="product_label_document">
    <t t-call="report.html_container">
       <t t-foreach="docs" t-as="o">
         <t t-call="report.external_layout">
         <div class="page">
         <table style="width:50%;">
        <tbody>
        <tr><td colspan="2"><b>O/T:</b> <span t-field="o.production_id.name"/></td></tr>
        <tr><td colspan="2"><img t-att-src="'/report/barcode/Code128/%s' % 'test-0001'" style="width:100%;height:25px"/>          </td></tr>
         </tbody>
        </table>
        </div>
       </t>
    </t>
</t>
</template>
</data>
</openerp>

call report:
def get_label(self, cr, uid, ids, context=None):
    if ids:
       if not isinstance(ids, list):
           ids = [ids]
       context = dict(context or {}, active_ids=ids, active_model=self._name)
   return {
      'type': 'ir.actions.report.xml',
      'report_name': 'mrp.product_label_document',
      'context': context,
   }
404 error:
2015-10-15 20:09:16,239 24721 INFO None werkzeug: 127.0.0.1 - - [15/Oct/2015 20:09:16] "GET /report/barcode/Code128/test-0001 HTTP/1.1" 404 -
0
Avatar
Discard
Axel Mendoza

I tried http://localhost:8069/report/barcode/Code128/test-0001 and the barcode is returned without problem, I have another report which also shows one barcode and it works perfectly, but with this example I get a 404 Error, the unique difference is the way of calling the report, the report that show me the barcode is called from Print option at page header, and this report is called from method.

Avatar
Axel Mendoza
Best Answer

To generate a barcode using that way you need to have installed reportlab dependency and the module 'report' that it's auto-installed when base and web modules are installed, check those prerequisites and if they are ok you could always test in the browser your barcode image using this url in your case:

http://localhost:8069/report/barcode/Code128/test-0001

that will return you the barcode image generated, If some other error shows in the logs post it here. If the barcode not get generated and the logs doesn't show anything, then you need to debug what happens at /openerp/addons/report/controllers/main.py on the report_barcode method.

===========================================================================================

I test it and debug it and seems that you cannot do that because the request to the controller came with no session_id and also no database to use and get dropped with a 404. Your alternative could be to directly generate the barcode image using the same code of the barcode controller but used from a report parser. Define a function in a parser like:

import base64
from openerp.report import report_sxw
from reportlab.graphics.barcode import createBarcodeDrawing

class barcode_report_parser(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(barcode_report_parser, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'barcode': self.barcode,
})
def barcode(self, type, value, width=600, height=100, humanreadable=0):
width, height, humanreadable = int(width), int(height), bool(humanreadable)
barcode_obj = createBarcodeDrawing(
type, value=value, format='png', width=width, height=height,
humanReadable = humanreadable
)
return base64.encodestring(barcode_obj.asString('png'))

In the report template define your image like this:

<img t-att-src="'data:image/png;base64,%s' % barcode('Code128','test-0001')" style="width:100%;height:25px"/>
5
Avatar
Discard
Axel Mendoza

check the answer update

Adnier Rosello
Author

That's right, now the barcode shown in the report

Avatar
Boubaker Abdallah
Best Answer

best answer helpful
i have upgrade reportlab libs
>> python3 -m pip install --upgrade reportlab
work fine

1
Avatar
Discard
CARLOS ALBERTO GARCIA BRIZUELA

For me, an extra step was that the solution was only applied after rebooting the entire server system.

Hope it helps!

CARLOS ALBERTO GARCIA BRIZUELA

I used: pip3 install reportlab --upgrade

Avatar
Matteo
Best Answer

where can I find the module report?

is it OCa module?

0
Avatar
Discard
Houssine BAKKALI

the report module has been integrated with the web module

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
How to set any footer in only last page in qweb report odoo? Solved
odoo qweb-report
Avatar
Avatar
Avatar
4
Mar 21
15983
How to print employee details like dept,phone in qweb report Solved
odoo qweb-report
Avatar
Avatar
Avatar
3
Apr 18
8708
Qweb showing all the subjects listed in an exam session odoo 12
variable odoo qweb-report
Avatar
0
May 19
4004
How do I go about this error? I am trying to uninstall a module
odoo
Avatar
0
Nov 25
3313
(#iberia#)¿Cómo llamar a Iberia desde Panamá?
odoo
Avatar
0
Oct 25
385
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now