Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joshua
erp5
Commits
718a48ae
Commit
718a48ae
authored
Apr 10, 2012
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add an external method to generate barcode image.
parent
c932a5ad
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
2 deletions
+69
-2
bt5/erp5_base/ExtensionTemplateItem/BarcodeUtils.py
bt5/erp5_base/ExtensionTemplateItem/BarcodeUtils.py
+35
-0
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_generateBarcodeImage.xml
...Item/portal_skins/erp5_base/Base_generateBarcodeImage.xml
+28
-0
bt5/erp5_base/bt/change_log
bt5/erp5_base/bt/change_log
+3
-0
bt5/erp5_base/bt/revision
bt5/erp5_base/bt/revision
+1
-1
bt5/erp5_base/bt/template_extension_id_list
bt5/erp5_base/bt/template_extension_id_list
+2
-1
No files found.
bt5/erp5_base/ExtensionTemplateItem/BarcodeUtils.py
0 → 100644
View file @
718a48ae
def
generateBarcodeImage
(
self
,
barcode_type
,
data
):
# huBarcode's DataMatrix support has limitation for data size.
# huBarcode's QRCode support is broken.
# more 1-D barcode types can be added by pyBarcode library.
barcode_type
=
barcode_type
.
lower
()
if
barcode_type
==
'datamatrix'
:
from
subprocess
import
Popen
,
PIPE
process
=
Popen
([
'dmtxwrite'
],
stdin
=
PIPE
,
stdout
=
PIPE
,
stderr
=
PIPE
,
close_fds
=
True
)
output
,
error
=
process
.
communicate
(
input
=
data
)
elif
barcode_type
==
'ean13'
:
from
hubarcode.ean13
import
EAN13Encoder
encoder
=
EAN13Encoder
(
data
)
output
=
encoder
.
get_imagedata
()
elif
barcode_type
==
'code128'
:
from
hubarcode.code128
import
Code128Encoder
encoder
=
Code128Encoder
(
data
)
output
=
encoder
.
get_imagedata
()
elif
barcode_type
==
'qrcode'
:
import
qrcode
from
cStringIO
import
StringIO
fp
=
StringIO
()
img
=
qrcode
.
make
(
data
)
img
.
save
(
fp
,
format
=
'png'
)
fp
.
seek
(
0
)
output
=
fp
.
read
()
else
:
raise
NotImplementedError
,
'barcode_type=%s is not supported'
%
barcode_type
RESPONSE
=
self
.
REQUEST
.
RESPONSE
RESPONSE
.
setHeader
(
'Content-Type'
,
'image/png'
)
RESPONSE
.
setHeader
(
'Content-Length'
,
len
(
output
))
return
output
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_generateBarcodeImage.xml
0 → 100644
View file @
718a48ae
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ExternalMethod"
module=
"Products.ExternalMethod.ExternalMethod"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_function
</string>
</key>
<value>
<string>
generateBarcodeImage
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
BarcodeUtils
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_generateBarcodeImage
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_base/bt/change_log
View file @
718a48ae
2012-04-10 Kazuhiko
* add an external method to generate barcode image.
2011-11-11 arnaud.fontaine
2011-11-11 arnaud.fontaine
* Fix document conversion not being performed when data is set directly.
* Fix document conversion not being performed when data is set directly.
...
...
bt5/erp5_base/bt/revision
View file @
718a48ae
1019
1020
\ No newline at end of file
\ No newline at end of file
bt5/erp5_base/bt/template_extension_id_list
View file @
718a48ae
BaseMigration
BaseMigration
\ No newline at end of file
BarcodeUtils
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment