QR code generation in OpenERP

What is QR code ???

A QR code (Quick Response code) is a type of matrix barcode or two-dimensional code designed to be read by smartphones. The code consists of black modules arranged in a square pattern on a white background. The information encoded may be text, a URL, or other data. The QR code is one of the most popular types of two-dimensional barcodes. The QR code was designed to allow its contents to be decoded at high speed. The reason why they are more useful than a standard barcode is that they can store (and digitally present) much more data, including url links, geo coordinates, and text. The other key feature of QR Codes is that instead of requiring a chunky hand-held scanner to scan them, many modern cell phones can scan them.

How QR code can be generated using a python script ?????

First of all you need the python file qrtools.py, copy it in the folder where you running the code. You can get this file at http://code.google.com/p/qtqr/source/browse/qrtools.py. QR code can be generated by a simple python script. To generate a qrcode, create a python file , eg: qrgenerate.py, with the code given below and run the code.

from qrtools import QR
     code = u"A QR code is a type of matrix barcode designed to be read by smartphones"
     qrCode = QR(data=code)
     qrCode.encode()
     print qrCode.filename

You can run the code by typing ‘python qrgenerate.py’ in the terminal.  Please note that the data argument must be a unicode object if you are going to use non-ascii characters. To encode the text we need to call the encode() method of our new QR object. By printing the filename attribute, we can get path of the created file.

You can modify the attributes of the generated QR Code by passing personalized values to the other parameters of the __init__ method, such as pixel_size, margin_size.
ie, qrCode = QR(data=code, pixel_size=10, margin_size=4 )

How QR code is incorporated in OpenERP ?????

QR code can also be generated with OpenERP. To generate a QRcode in OpenERP, install the module tr_barcode. On installing this module, there will be a new menu Barcode. Goto the menu Barcode/Barcode/Barcode and Create a new record by entering the text at Barcode field and select Type as ‘QR’. On pressing the button “Generate Barcode Image”, the image will be created at the Data field. The module tr_barcode is attached.

Comments

sahad: I got same error as you got,Please tell me,How can i solve this".

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Oswaldo says:

    help pleace …. error here
    Environment Information :
    System : Windows-32bit-SP1,_v.178
    OS Name : nt
    Operating System Release :
    Operating System Version : 32bit
    Operating System Architecture : 32bit
    Operating System Locale : es_VE.cp1252
    Python Version : 2.5.2
    OpenERP-Client Version : 6.0.3
    Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
    File “netsvc.pyo”, line 489, in dispatch
    File “service\web_services.pyo”, line 599, in dispatch
    File “osv\osv.pyo”, line 122, in wrapper
    File “osv\osv.pyo”, line 176, in execute
    File “osv\osv.pyo”, line 167, in execute_cr
    File “C:\Program Files\OpenERP 6.0\Server\addons\tr_barcode\tr_barcode.py”, line 53, in generate_image
    File “C:\Program Files\OpenERP 6.0\Server\addons\tr_barcode\tr_barcode.py”, line 42, in get_image
    File “reportlab\graphics\shapes.pyo”, line 780, in asString
    File “reportlab\graphics\renderPM.pyo”, line 656, in drawToString
    File “reportlab\graphics\renderPM.pyo”, line 651, in drawToFile
    File “reportlab\graphics\renderPM.pyo”, line 637, in drawToPMCanvas
    File “reportlab\graphics\renderPM.pyo”, line 50, in draw
    File “reportlab\graphics\renderbase.pyo”, line 198, in draw
    File “reportlab\graphics\renderPM.pyo”, line 93, in initState
    File “reportlab\graphics\renderPM.pyo”, line 87, in applyState
    File “reportlab\graphics\renderPM.pyo”, line 368, in setFont
    File “reportlab\graphics\renderPM.pyo”, line 221, in _setFont
    RenderPMError: Can’t setFont(Times-Roman) missing the T1 files?
    Originally : makeT1Font() argument 2 must be string, not None
    in openerp 6.0.3

    1. janeesh says:

      The solution is to download the fonts from the reportlab site Or use the link below.

      http://www.findthatfile.com/search-11092018-hZIP/winrar-winzip-download-pfbfer.zip.htm

      Now, unzip the files to the fonts directory in reportlab.

      I am using Ubuntu10.04. In my case the path is /usr/lib/python2.6/dist-packages/reportlab/fonts

      1. Lolztitan says:

        Your approach to this topic is unique and informative. I am writing an article for our school paper and this post has helped me. Thanks. 

      2. janeesh says:

        Extract the pfbfer.zip file in the attached module to the fonts directory in reportlab. In ubuntu the path is /usr/lib/python2.6/dist-packages/reportlab/fonts.

        1. emna says:

          Hello i don’t inderstand where i’ll extract the pfbfer.zip in windows
          can you help me please
          regards

        2. Candidoskie P. Berdin II says:

          Hi Janeesh, I already download pfbfer.zip and extract under C:\Program Files\OpenERP 7.0alpha-20121206-000102\Server\server\reportlab\fonts directory but error still the same. i'm using windows 7 and openerp 6.1 thanks and hope to hear solution regarding this issue.

    2. same error found.
      i’m using openerp 6.1
      OS windows 7
      here’s error
      Environment Information :
      System : Windows-post2008Server-6.1.7600
      OS Name : nt
      Operating System Release : post2008Server
      Operating System Version : 6.1.7600
      Operating System Architecture : 32bit
      Operating System Locale : en_US.cp1252
      Python Version : 2.6.5
      OpenERP-Client Version : 6.1.1
      Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
      File “C:\Program Files\OpenERP 6.1-20121208-001656\Server\server\.\openerp\service\netrpc_server.py”, line 64, in run
      File “C:\Program Files\OpenERP 6.1-20121208-001656\Server\server\.\openerp\netsvc.py”, line 360, in dispatch_rpc
      File “C:\Program Files\OpenERP 6.1-20121208-001656\Server\server\.\openerp\service\web_services.py”, line 586, in dispatch
      File “C:\Program Files\OpenERP 6.1-20121208-001656\Server\server\.\openerp\osv\osv.py”, line 121, in wrapper
      File “C:\Program Files\OpenERP 6.1-20121208-001656\Server\server\.\openerp\osv\osv.py”, line 176, in execute
      File “C:\Program Files\OpenERP 6.1-20121208-001656\Server\server\.\openerp\osv\osv.py”, line 164, in execute_cr
      File “C:\Program Files\OpenERP 6.1-20121208-001656\Server\server\openerp\addons\tr_barcode.zip\tr_barcode\wizard\tr_barcode_wizard.py”, line 98, in create_barcode_record
      File “C:\Program Files\OpenERP 6.1-20121208-001656\Server\server\openerp\addons\tr_barcode.zip\tr_barcode\tr_barcode.py”, line 73, in generate_image
      File “C:\Program Files\OpenERP 6.1-20121208-001656\Server\server\openerp\addons\tr_barcode.zip\tr_barcode\tr_barcode.py”, line 62, in get_image
      File “reportlab\graphics\shapes.pyo”, line 780, in asString
      File “reportlab\graphics\renderPM.pyo”, line 656, in drawToString
      File “reportlab\graphics\renderPM.pyo”, line 651, in drawToFile
      File “reportlab\graphics\renderPM.pyo”, line 637, in drawToPMCanvas
      File “reportlab\graphics\renderPM.pyo”, line 50, in draw
      File “reportlab\graphics\renderbase.pyo”, line 198, in draw
      File “reportlab\graphics\renderPM.pyo”, line 93, in initState
      File “reportlab\graphics\renderPM.pyo”, line 87, in applyState
      File “reportlab\graphics\renderPM.pyo”, line 368, in setFont
      File “reportlab\graphics\renderPM.pyo”, line 221, in _setFont
      RenderPMError: Can’t setFont(Times-Roman) missing the T1 files?
      Originally : makeT1Font() argument 2 must be string, not None

  2. Wil says:

    Hi Janeesh,
    I wanted to import the tr-barcode zip file and received the following error:
    Error !
    Can not create the module file: /home/pathofinder/openerp-server-5.0.9/bin/addons/tr_barcode/.bzr/repository/indices.zip !
    Any clue on how to solve this?
    Thank’s for your feedback.

  3. Yoda says:

    I have installed as described and can do barcodes all but QR.
    When I write a small script using get_codes() QR is not in the list
    I am using 10.04.4 LTS
    Is this to do with reportlab?
    Standard39
    Extended39
    EAN13
    FIM
    EAN8
    Extended93
    USPS_4State
    Codabar
    MSI
    POSTNET
    Code11
    Standard93
    I2of5
    Code128
    Thanks

  4. e ziggi günstig says:

    Hi theгe, Ι enjoу reading thгough your artіcle pоst. I liκe to write a little cοmment to suppоrt you.

  5. emna says:

    Hello,
    I have the following error when i try to generate a QR barcode:
    Traceback (most recent call last):
    File “netsvc.pyo”, line 489, in dispatch
    File “service\web_services.pyo”, line 599, in dispatch
    File “osv\osv.pyo”, line 122, in wrapper
    File “osv\osv.pyo”, line 176, in execute
    File “osv\osv.pyo”, line 167, in execute_cr
    File “C:\Program Files\OpenERP 6.0\Server\addons\tr_barcode\wizard\tr_barcode_wizard.py”, line 78, in create_barcode_record
    File “C:\Program Files\OpenERP 6.0\Server\addons\tr_barcode\tr_barcode.py”, line 53, in generate_image
    File “C:\Program Files\OpenERP 6.0\Server\addons\tr_barcode\tr_barcode.py”, line 42, in get_image
    File “reportlab\graphics\shapes.pyo”, line 780, in asString
    File “reportlab\graphics\renderPM.pyo”, line 656, in drawToString
    File “reportlab\graphics\renderPM.pyo”, line 651, in drawToFile
    File “reportlab\graphics\renderPM.pyo”, line 637, in drawToPMCanvas
    File “reportlab\graphics\renderPM.pyo”, line 50, in draw
    File “reportlab\graphics\renderbase.pyo”, line 198, in draw
    File “reportlab\graphics\renderPM.pyo”, line 93, in initState
    File “reportlab\graphics\renderPM.pyo”, line 87, in applyState
    File “reportlab\graphics\renderPM.pyo”, line 368, in setFont
    File “reportlab\graphics\renderPM.pyo”, line 221, in _setFont
    RenderPMError: Can’t setFont(Times-Roman) missing the T1 files?
    Originally : makeT1Font() argument 2 must be string, not None
    can you help me please
    regards

    1. Anonymous says:

      hello
      I have the same error that you ;can you help me if you have to find a solution.

  6. tandarts apeldoorn loeff says:

    Hi, this weekend is good in support of me, because this occasion i am reading this great educational post here at my residence.

  7. tandarts prijzen says:

    Hi! This is my first comment here so I just wanted to give a quick shout out and say I truly enjoy reading your blog posts. Can you suggest any other blogs/websites/forums that deal with the same subjects? Thank you!

  8. Anonymous says:

    Traceback (most recent call last):
    File “/home/eagle/openerp/osv/osv.py”, line 121, in wrapper
    return f(self, dbname, *args, **kwargs)
    File “/home/eagle/openerp/osv/osv.py”, line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File “/home/eagle/openerp/osv/osv.py”, line 164, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
    File “/home/eagle/tr_barcode/tr_barcode.py”, line 98, in generate_image
    hr=self_obj.hr_form)
    File “/home/eagle/tr_barcode/tr_barcode.py”, line 86, in get_image
    qrCode.encode()
    File “/home/eagle/tr_barcode/qrtools.py”, line 117, in encode
    self.data_to_string()
    File “/usr/lib/python2.7/subprocess.py”, line 679, in __init__
    errread, errwrite)
    File “/usr/lib/python2.7/subprocess.py”, line 1249, in _execute_child
    raise child_exception
    OSError: [Errno 2] No such file or directory
    How to solve this error ?? maybe we must set path an image ??

    1. sahad says:

      I got same error as you got,Please tell me,How can i solve this

© 2020 Zesty Beanz Pvt Ltd All Rights Reserved.