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

How to create barcodes in webkit reports?

Subscribe

Get notified when there's activity on this post

This question has been flagged
webkitbarcode
4 Replies
16330 Views
Avatar
Yannick Payot

How to create EAN13 and code39 barcode in a custom webkit report?

0
Avatar
Discard
Avatar
Yannick Payot
Author Best Answer

As my previous answer was very limited here is an better one

Installing barcode on document

Requirements: Julius modules needs rsvg-convert install it:

apt-get install librsvg2-bin

One way is to install the julius modules accessible in lp:stock-logistic-barcode.

Let's say we want a barcode on our sale_order_webkit report

Install the module tr_barcode_on_sale_order

Then go on openerp and apply the install of the field x_barcode_id. In menu Settings -> Configuration -> Barcode Click on Apply

Adding a barcode in a report

Now your field generating barcode is ready on your document

To use it in you mako template:

${helper.embed_image('png', order.x_barcode_id.image)}

(where order is your sale_order browse record.)



Older version, simpler but very limited:

You can simply use a barcode font like http://www.barcodesinc.com/free-barcode-font/

First, install it on your server:

  • Place the fonts in the following folder: /usr/share/fonts
  • Run: fc-cache -fv

Now, we need to add a style in your CSS of the report or of the header.

Something like:

.barcode39 {
    font-family: "Free 3 of 9";
    font-size: 36pt;
}

And finnally use it like this:

<p class="barcode39">*${object.ref}*</p>

Note: you will need the * character to tell the scanner where to start and end reading the code.

5
Avatar
Discard
Houssine BAKKALI

Hi Yannick, I can't find the librsvg2-bin for windows easy_install don't recognize it and I didn't find an installer neither... Any tip for windows users??

Houssine BAKKALI

ok i've just solved the depency problem. Avoiding using the svg to png convertion... by generating direclty the barcode to the png format.

Nicholas Linn

The link doesn't seem to have a tr_barcode_on_sale_order module. Am i missing something or did it disappear?

Avatar
Yohanes Iwan Sugiarto
Best Answer

Here's a slightly different approach, this should work for any barcode types which couldn't be generated using barcode fonts, including 2D barcode PDF417, QR Code, etc

<%
import commands
commands.getoutput('barcode -b ' + l.product_id.default_code + ' -o /tmp/barcode.ps -e ean13 -g 450x200 -u mm')
commands.getoutput('ps2png /tmp/barcode.ps /tmp/barcode.png')
data_uri = open("/tmp/barcode.png", "rb").read().encode("base64")
%>
${helper.embed_image('png',data_uri,0,32)|n}

This involves 2 external command which should be installed on your server (I'm using Linux Ubuntu Server):

  1. barcode -> generates binary postcript file
  2. ps2png -> converts PS file to PNG
2
Avatar
Discard
Yannick Payot
Author

Thanks for your answer, I came up with another solution, which shouldn't be plateform specific. I updated my answer.

Yohanes Iwan Sugiarto

You are welcome, thanks for your idea too Yannick. Will try that someday.

Yannick Payot
Author

Forget about the not plateform specific, it needs librsvg2-bin package as it uses rsvg-convert

Avatar
Vince Vinet
Best Answer

You can now use the report_webkit_barcode module, available in OCA at:

https://github.com/OCA/webkit-tools/tree/7.0/report_webkit_barcode

This allows you to use ${helper.barcode(value) | u} in a webkit template to get a barcode. It supports all the barcodes supported by the RML reports.

 

2
Avatar
Discard
Abhishek H Menon

How can we apply the 'value'? ${helper.barcode(1234) | u}, is this code valid?

Vince Vinet

Yes, you can put ${helper.barcode(1234) | u} if that's the value you want. Depending on the barcode type, the value can be an integer, string or numeric string. It can also come from your objects (${helper.barcode(object.id) | u}).

Christian Werner

if I use the module, the gererated barcode is not scanable. The generated Image has some grey elements.

do you have an idea how to fix it?

Vince Vinet

Most likely if you cannot scan the images, it is because your barcode images were stretched from a small size. To fix this, you should pass in the appropriate width/height options.

Avatar
Houssine BAKKALI
Best Answer

In the getImage function of the tr_barcode class replace the following code by this following.

if code not in ['QR','qrcode']:
        try:
            ret_val = createBarcodeDrawing(code, value=str(value), **options)
        except Exception, e:
            raise osv.except_osv('Error', e)
        ret_val.save(formats=['png'], fnRoot='barcode', outDir='/tmp/')
        return base64.encodestring(open("/tmp/barcode.png","rb").read())
1
Avatar
Discard
Yannick Payot
Author

Nice, could you create a patch to send to julius ? If we can avoid a useless conversion forcing us to install another dependency and furthermore executing shell command I think it would be better.

Houssine BAKKALI

Ok I will see how to do it

Houssine BAKKALI

as far as I see the tr_barcode module is from Tech-Receptives Solutions and not Julius, which developped modules with a dependency on tr_barcode

Houssine BAKKALI

Hi Yannick, I'm not used with making merge or patch proposale. Have you some tips or guidelines for this? thanks

Yannick Payot
Author

The branch you want to modify is lp:stock-logistic-barcode

You need to push your branch on launchpad with the commited changes: (to commit changes bzr ci -m [my message])

bzr push lp:~[username or group]/[project_name]/[whatever_you_want]

So in you case something like

bzr push lp:~houssine/stock-logistic-barcode/replace-svg-conversion

Then you go on launchpad on your registered branches. You will see your branch and in it a link Propose for merging. Just select the right branch and there you have your MP.

Houssine BAKKALI

thanks for you help!

I made a bug report yesterday and attached a patch file to it. Hoping it will be enough to be taken into account. Otherwise I'll do a merge proposal.

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
Can I remove the "Product Barcode Lookup" module from my database? Solved
barcode
Avatar
Avatar
Avatar
2
Sep 25
920
How can I customize product labels to show additional information?
barcode
Avatar
Avatar
Avatar
2
Sep 25
1306
Barcode - Process and Cancel MOs Using Barcodes (last chapter)
barcode
Avatar
0
Feb 25
2220
Default barcode nomenclature
barcode
Avatar
0
Dec 24
46
Find product by name scanning barcode & regex segmentation
barcode
Avatar
0
Dec 24
1859
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