Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
15739 Lượt xem

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">

    ${object.ean13}

    </barcode>

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?

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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">
${object.ean13}
</barcode>

do not insert spaces at the beginning of lines

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Is the Label module module available on V.7?

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 15
4051
1
thg 3 25
5310
Removing Barcode Đã xử lý
3
thg 7 21
4595
0
thg 3 16
3486
1
thg 3 15
3731