Non-ASCII characters not supported in RML barcodes

Bug #664345 reported by vrsb
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Confirmed
Wishlist
OpenERP's Framework R&D

Bug Description

Hello.
I make an RML report with barcode of "code128 " kind.
Is there a way to insert a special FNC1 symbol (field delimeter) in the barcode? This is required this because there are fields of variable length in barcode.

The Reportlab documentation says: "Code 128 is a very compact symbology that can encode the entire 128 character ASCII set, plus 4 special control codes, (FNC1-FNC4, expressed in the input string as \xf1 to \xf4)."

So Python code like "bar=code128.Code128("\xf412\xf134567890",xdim=100*mm)" works well.

But when i try to insert this symbol between <barCode> an </barCode> inside RML template i get:
File "reportlab\platypus\doctemplate.pyo", line 756, in build
  File "reportlab\platypus\doctemplate.pyo", line 649, in handle_flowable
  File "reportlab\platypus\frames.pyo", line 159, in _add
  File "reportlab\platypus\flowables.pyo", line 121, in wrap
  File "reportlab\graphics\barcode\common.pyo", line 107, in width
  File "reportlab\graphics\barcode\common.pyo", line 57, in _calculate
  File "reportlab\graphics\barcode\code128.pyo", line 243, in validate
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf1 in position 0: ordinal not in range(128)

Tried to insert it many ways: &#241; ñ; [['\xf1']] or [[u'xf1']]

I think something is wrong in trml2pdf.py... it transmits an unicode string where should be "simple" one

Revision history for this message
vrsb (shipilov555) wrote :

Seem I've found a way to correct it.
Using pached trml2pdf and inserting &#241; symbol in RML file.

Revision history for this message
vrsb (shipilov555) wrote :

Fixed

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hi, thanks for the report and providing the patch that works for you.

I guess this is yet another encoding conversion issue due to Python2.

BTW, hardcoding 'latin1' encoding is not a good idea in general, you should use 'utf-8' instead. You might even directly put the "ñ" character in your RML document then, as long as you configure your editor to properly write the RML in UTF-8.

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Wishlist
status: New → Confirmed
summary: - FNC1 symbol in barcode
+ Non-ASCII characters not supported in RML barcodes
Revision history for this message
vrsb (shipilov555) wrote :

Hi. Now am puzzled about how to read this symbol in OpenERP. For example, i set focus on the product field of some order/stock move/lot and read this barcode that consists of a few fields.
I tried to rewrite name_seach function to parse RE like r'^10(?P<lot>\d+)'+chr(29) to distinguish product code field.
Seems it just doesn't see <GS> symbol.
Do you have any idea?

Revision history for this message
Numérigraphe (numerigraphe) wrote :

vrsb, reading the data will be another problem, I propose we keep this bug report focused on writing the barcode in RML.
If your data is a GS1-128 or EAN-128 barcode: I wrote an exhaustive module to read and decode GS1-128 data, we can discuss it here : http://www.openerp.com/forum/topic18131.html.
Lionel

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.