Odoo Help


This community 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.


print product barcode on label

on 3/7/13, 9:20 AM 6,778 views

I want to print barcode with Label module, on OpenERP 6.1

I go to "settings -> customization -> Labels -> Label templates" and I edit one of the templates. To print barcode I tried:

  • first, a harcoded code

    <barcode x="1cm" y="1cm" height="1cm" code="EAN13">7501031311309</barcode>

  • second, I tried with ${object.ean13}:

    <barcode x="1cm" y="1cm" height="1cm" code="EAN13">${object.ean13}</barcode>

  • finally on 3 lines:

    <barcode x="1cm" y="1cm" height="1cm" code="EAN13">



the first works, but always the same barcode, obviously.

the second I get:

Illegal assignment of '${object.ean' to 'value' in class Ean13BarcodeWidget

(<type 'exceptions.AttributeError'>, AttributeError("Illegal assignment of '${object.ean' to 'value' in class Ean13BarcodeWidget",), <traceback object at 0xe0c9784>)

and the third:

Illegal assignment of '<para style=' to 'value' in class Ean13BarcodeWidget

(<type 'exceptions.AttributeError'>, AttributeError("Illegal assignment of '<para style=' to 'value' in class Ean13BarcodeWidget",), <traceback object at 0xccb9554>)

How I should configure the barcode tag to get ean13 from each product?

On 3/8/13, 7:02 AM

had to change label module:

diff --git a/openerp/addons_extra/label/label_report_engine.py b/openerp/addons_extra/label/label_report_engine.py
index b1419d6..edce844 100644
--- a/openerp/addons_extra/label/label_report_engine.py
+++ b/openerp/addons_extra/label/label_report_engine.py
@@ -211,7 +211,11 @@ class report_label_xsl(report_rml):
                 if text_line: # Line that includes text o fields to print
                     rline = re.sub(r'(<([\w/]+)\s*[^>]*>)', r'</xsl:text>\1<xsl:text>', line) # To put <...> report tags outside <xsl:text>...</xsl:text>
                     rline = re.sub(r'\$\{([\w\.]+)\s*[^}]*\}', r'</xsl:text><xsl:value-of select="\1"/><xsl:text>', rline)
-                    rline = '    <para style="nospace"><xsl:text>%s</xsl:text></para>\n' % rline
+                    # barCode expects it's value without <para> tags
+                    if re.search(r'object\.ean13', line):
+                        rline = '<xsl:text>%s</xsl:text>\n' % rline
+                    else:
+                        rline = '    <para style="nospace"><xsl:text>%s</xsl:text></para>\n' % rline
                     tline = re.sub(r'(<[^>]*>)', '', line) # To exclude <...> tags
                     tline = re.sub(r'(\$\{([\w\.]+)\s*[^}]*\})', r'<\2>\1</\2>', tline)
                 else: # Line that only includes report tags like <tr>, <td>, <blockTable>, <nextFrame/>, ... to control the report format

and use barCode like in the 3rd example

<barcode x="1cm" y="1cm" height="1cm" code="EAN13">

do not insert spaces at the beginning of lines

On 5/24/13, 7:04 AM

Is the Label module module available on V.7?

I have no idea, still working on 6.1, you should check at launchpad

on 6/6/13, 11:31 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)


Asked: 3/7/13, 9:20 AM
Seen: 6778 times
Last updated: 3/16/15, 8:10 AM