Merge lp:~camptocamp/openobject-addons/6.1-webkit_report-image_helper-20120719 into lp:openobject-addons/6.1

Proposed by Yannick Vaucher @ Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/6.1-webkit_report-image_helper-20120719
Merge into: lp:openobject-addons/6.1
Diff against target: 69 lines (+14/-13)
2 files modified
report_webkit/__openerp__.py (+3/-2)
report_webkit/report_helper.py (+11/-11)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/6.1-webkit_report-image_helper-20120719
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+115770@code.launchpad.net

Description of the change

Fix and improve the helper for inserting images in webkit report

With webkit it is better to use css style for height and width than elements attributes.

To post a comment you must log in.

Unmerged revisions

6897. By Yannick Vaucher @ Camptocamp

[FIX] webkit_report - using style in image helper instead of attributes, this allow to use metric dimensions for images + [IMP] image helper to accept other units than px

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'report_webkit/__openerp__.py'
2--- report_webkit/__openerp__.py 2012-01-31 13:36:57 +0000
3+++ report_webkit/__openerp__.py 2012-07-19 15:35:24 +0000
4@@ -64,8 +64,9 @@
5 PDF. Version 0.9.9 or later is necessary, and can be found at http://code.google.com/p/wkhtmltopdf/
6 for Linux, Mac OS X (i386) and Windows (32bits).
7
8-After installing the library on the OpenERP Server machine, you need to set the
9-path to the ``wkthtmltopdf`` executable file on each Company.
10+After installing the library on the OpenERP Server machine, you need to set
11+the path to the ``wkthtmltopdf`` executable file in a system parameter named ``webkit_path``
12+in Settings -> Customization -> System Parameters
13
14 If you are experiencing missing header/footer problems on Linux, be sure to
15 install a "static" version of the library. The default ``wkhtmltopdf`` on
16
17=== modified file 'report_webkit/report_helper.py'
18--- report_webkit/report_helper.py 2011-12-19 16:54:40 +0000
19+++ report_webkit/report_helper.py 2012-07-19 15:35:24 +0000
20@@ -39,26 +39,26 @@
21 self.uid = uid
22 self.pool = pooler.get_pool(self.cursor.dbname)
23 self.report_id = report_id
24-
25- def embed_image(self, type, img, width=0, height=0) :
26+
27+ def embed_image(self, type, img, width=0, height=0, unit="px") :
28 "Transform a DB image into an embedded HTML image"
29
30 if width :
31- width = 'width="%spx"'%(width)
32+ width = 'width: %s%s;'%(width, unit)
33 else :
34 width = ' '
35 if height :
36- height = 'height="%spx"'%(height)
37+ height = 'height: %s%s;'%(height, unit)
38 else :
39 height = ' '
40- toreturn = '<img %s %s src="data:image/%s;base64,%s" />'%(
41+ toreturn = '<img style="%s%s" src="data:image/%s;base64,%s" />'%(
42 width,
43 height,
44 type,
45 str(img))
46 return toreturn
47-
48-
49+
50+
51 def get_logo_by_name(self, name):
52 """Return logo by name"""
53 header_obj = self.pool.get('ir.header_img')
54@@ -74,11 +74,11 @@
55
56 head = header_obj.browse(self.cursor, self.uid, header_img_id)
57 return (head.img, head.type)
58-
59- def embed_logo_by_name(self, name, width=0, height=0) :
60+
61+ def embed_logo_by_name(self, name, width=0, height=0, unit="px") :
62 """Return HTML embedded logo by name"""
63 img, type = self.get_logo_by_name(name)
64- return self.embed_image(type, img, width, height)
65-
66+ return self.embed_image(type, img, width, height, unit)
67+
68
69 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: