Odoo Help


1 Answer
Rakesh Vadeghar
25-03-19 08:46
hope this works
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', o.your_sequence, 600, 100)" style="width:300px;height:50px"/>

Haresh Kansara
25-03-19 10:56

Thanks Rakesh,

It's working for report/Qweb side. But how to do this for backend side, means when i am creating new record and when i save that record then i am generating sequence and set to field and i have taken one image(Binary field) to store barcode for the generated sequence then how it is possible in backend side,

I know that when we run /report/barcode.. controller then it generate barcode and return. But for backend side? how to easily call that controller or any easier way??

Thank you for help.. :D

Rakesh Vadeghar
26-03-19 01:55

hope this helps


def create(self, vals):

res = super(yourmodel, self).create(vals)

"""Contoller able to render barcode images thanks to reportlab.


<img t-att-src="'/report/barcode/QR/%s' % o.name"/>

<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' %

('QR', o.name, 200, 200)"/>

:param type: Accepted types: 'Codabar', 'Code11', 'Code128', 'EAN13', 'EAN8', 'Extended39',

'Extended93', 'FIM', 'I2of5', 'MSI', 'POSTNET', 'QR', 'Standard39', 'Standard93',

'UPCA', 'USPS_4State'

:param humanreadable: Accepted values: 0 (default) or 1. 1 will insert the readable value

at the bottom of the output image



barcode = self.env['ir.actions.report'].barcode(type= param_type, value='your_sequence_number', width=width, height=height,

humanreadable='param humanreadable')

except (ValueError, AttributeError):

raise UserWarning('Cannot convert into barcode.')

import base64

barcode = base64.b64encode(barcode)

self.your_binary_field = barcode


Stel een vraag
Keep Informed
1 volger(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now