[SOLVED] QRCode

[SOLVED] QRCode

Postby uxbod » Tue Nov 06, 2012 11:36 am

Hello:

is it possible to generate a QR Code using Aeroo ? I guess that really depends on the barcode() command does it not ? Is that the stock function being called or direct from the Aeroo code base ?

Thank you.
Last edited by uxbod on Wed Nov 07, 2012 1:20 pm, edited 1 time in total.
uxbod
 
Posts: 14
Joined: Tue Oct 30, 2012 5:45 pm

Re: QRCode

Postby sraps » Tue Nov 06, 2012 11:17 pm

Hi,
at the moment there is no built-in function for Aeroo. Moreover barcode fx is for "bar" like codes.

But you can install any QR python library, import and use it from parser. At the moment we're using QR codes this way, for ourselves.

But, we're planning to include some python native QR code generator in Aeroo package.

BR
Kaspar
sraps
 
Posts: 403
Joined: Mon May 04, 2009 10:04 pm

Re: QRCode

Postby uxbod » Tue Nov 06, 2012 11:53 pm

Evening Kaspar

Thank you for responding. May I ask which QR library you chose? am thinking this one http://pypi.python.org/pypi/qrcode/2.0 ?

BR.

P.
uxbod
 
Posts: 14
Joined: Tue Oct 30, 2012 5:45 pm

Re: QRCode

Postby uxbod » Wed Nov 07, 2012 1:18 am

OK. Have tried to create a new parser, after installing the Python QR library, and the following throws an error
Code: Select all
try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

import qrcode

class Parser(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(Parser, self).__init__(cr, uid, name, context)
        self.localcontext.update({
          'makeQRcode':self.makeQRcode,
        })

    def makeQRcode(self, name):

      im = qrcode.make('%s') % name
      tf = StringIO()
      im.save(tf, 'png')
 
      return tf, 'image/png'
I took the makeQRcode section from how you do it is barcode.py. The error I am getting is
Code: Select all
Aeroo Reports: Error while generating the report.
unsupported operand type(s) for %: 'instance' and 'unicode'
unsupported operand type(s) for %: 'instance' and 'unicode'
For more reference inspect error logs.

(<type 'exceptions.Exception'>, Exception(u'Aeroo Reports: Error while generating the report.', TypeError("unsupported operand type(s) for %: 'instance' and 'unicode'",), "unsupported operand type(s) for %: 'instance' and 'unicode'", u'For more reference inspect error logs.'), <traceback object at 0x7f748a83fb90>)
Any help with resolving this would be very much appreciated.
uxbod
 
Posts: 14
Joined: Tue Oct 30, 2012 5:45 pm

Re: QRCode

Postby uxbod » Wed Nov 07, 2012 1:03 pm

Python is a whole new learning process! :) Managed to resolve the issues and end up with a QRCode on my invoice :D
Code: Select all
try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

import qrcode

class Parser(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(Parser, self).__init__(cr, uid, name, context)
        self.localcontext.update({
          'makeQRcode':self.makeQRcode,
        })

    def makeQRcode(self, name=None, size=2):

      self.name = name
      self.size = size

      qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=size)
      qr.add_data(name)
      qr.make(fit=True)
      im = qr.make_image()
      tf = StringIO()
      im.save(tf, 'png')

      size_x = str(im.size[0]/96.0)+'in'
      size_y = str(im.size[1]/96.0)+'in'

      return tf, 'image/png', size_x, size_y
within your ODT and frame just specify
Code: Select all
image: makeQRcode(o.number,2)
The idea will be to specify the portal web address pointing to the invoice PDF.
uxbod
 
Posts: 14
Joined: Tue Oct 30, 2012 5:45 pm

Re: [SOLVED] QRCode

Postby troyanderson » Tue Mar 26, 2013 5:53 am

I am not a professional technical developer and I just want to know what sdk or component do I need so I can generate QR code in Invoice.










Tags: Generate, QR code, Invoice
troyanderson
 
Posts: 1
Joined: Tue Mar 26, 2013 5:47 am


Return to Aeroo Reports & OpenOffice.org Reporting Engine

cron
Copyright © 2001 Alistek Ltd., ALL RIGHTS RESERVED