Hi All,
I want to generate QR code for Product information since i am unable to get the information of QR code generation in odoo.10 for any module..?Can anyone help me with my question.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi All,
I want to generate QR code for Product information since i am unable to get the information of QR code generation in odoo.10 for any module..?Can anyone help me with my question.
You can made your own module. I did, using qrcode library. https://pypi.python.org/pypi/qrcode
import qrcode
import base64
import cStringIO
class QrGenerator(osv.osv):
_inherit = 'product.template'
_columns = {
'qr_product': fields.binary('QR Product'),
'qr_product_name': fields.char(default="product_qr.png")
}
def generate_product_sku(self, cr, uid, ids, context=None):
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=20,
border=4,
)
name = self.browse(cr, uid, ids, context).default_code+'_Product.png'
qr.add_data(self.browse(cr, uid, ids, context).default_code) #you can put here any attribute SKU in my case
qr.make(fit=True)
img = qr.make_image()
buffer = cStringIO.StringIO()
img.save(buffer, format="PNG")
img_str = base64.b64encode(buffer.getvalue())
self.write(cr, uid, ids, {'qr_product': img_str,'qr_product_name':name})
#################################################################
for the new API just have to change some code (Note: I don't tested this code, but must work well ):
from openerp import models, fields, api
import qrcode
import base64
import cStringIO
class QrGenerator(models.Model):
_inherit = 'product.template'qr_product = fields.Binary('QR Product')
qr_product_name = fields.Char(default="product_qr.png")
def generate_product_sku(self):
qr = qrcode.QRCode(version=1,error_correction=qrcode.constants.ERROR_CORRECT_L,box_size=20,border=4,)
name = self.default_code+'_Product.png'
qr.add_data(self.default_code) #you can put here any attribute SKU in my case
qr.make(fit=True)
img = qr.make_image()
buffer = cStringIO.StringIO()
img.save(buffer, format="PNG")
img_str = base64.b64encode(buffer.getvalue())
self.write({'qr_product': img_str,'qr_product_name':name})
Hello,
You have any solution for new api odoov10 ?
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Apr 25
|
118 | ||
|
1
Nov 16
|
4305 | ||
|
1
Mar 15
|
5243 | ||
|
0
Dec 24
|
3253 | ||
|
1
Mar 21
|
6265 |
Display QR Code: https://learnopenerp.blogspot.com/2022/06/generate-qr-code-for-qweb-report-redirect-to-url-odoo.html