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
=== modified file 'report_webkit/__openerp__.py'
--- report_webkit/__openerp__.py 2012-01-31 13:36:57 +0000
+++ report_webkit/__openerp__.py 2012-07-19 15:35:24 +0000
@@ -64,8 +64,9 @@
64PDF. Version 0.9.9 or later is necessary, and can be found at http://code.google.com/p/wkhtmltopdf/64PDF. Version 0.9.9 or later is necessary, and can be found at http://code.google.com/p/wkhtmltopdf/
65for Linux, Mac OS X (i386) and Windows (32bits).65for Linux, Mac OS X (i386) and Windows (32bits).
6666
67After installing the library on the OpenERP Server machine, you need to set the67After installing the library on the OpenERP Server machine, you need to set
68path to the ``wkthtmltopdf`` executable file on each Company.68the path to the ``wkthtmltopdf`` executable file in a system parameter named ``webkit_path``
69in Settings -> Customization -> System Parameters
6970
70If you are experiencing missing header/footer problems on Linux, be sure to71If you are experiencing missing header/footer problems on Linux, be sure to
71install a "static" version of the library. The default ``wkhtmltopdf`` on72install a "static" version of the library. The default ``wkhtmltopdf`` on
7273
=== modified file 'report_webkit/report_helper.py'
--- report_webkit/report_helper.py 2011-12-19 16:54:40 +0000
+++ report_webkit/report_helper.py 2012-07-19 15:35:24 +0000
@@ -39,26 +39,26 @@
39 self.uid = uid39 self.uid = uid
40 self.pool = pooler.get_pool(self.cursor.dbname)40 self.pool = pooler.get_pool(self.cursor.dbname)
41 self.report_id = report_id41 self.report_id = report_id
42 42
43 def embed_image(self, type, img, width=0, height=0) :43 def embed_image(self, type, img, width=0, height=0, unit="px") :
44 "Transform a DB image into an embedded HTML image"44 "Transform a DB image into an embedded HTML image"
4545
46 if width :46 if width :
47 width = 'width="%spx"'%(width)47 width = 'width: %s%s;'%(width, unit)
48 else :48 else :
49 width = ' '49 width = ' '
50 if height :50 if height :
51 height = 'height="%spx"'%(height)51 height = 'height: %s%s;'%(height, unit)
52 else :52 else :
53 height = ' '53 height = ' '
54 toreturn = '<img %s %s src="data:image/%s;base64,%s" />'%(54 toreturn = '<img style="%s%s" src="data:image/%s;base64,%s" />'%(
55 width,55 width,
56 height,56 height,
57 type, 57 type,
58 str(img))58 str(img))
59 return toreturn59 return toreturn
60 60
61 61
62 def get_logo_by_name(self, name):62 def get_logo_by_name(self, name):
63 """Return logo by name"""63 """Return logo by name"""
64 header_obj = self.pool.get('ir.header_img')64 header_obj = self.pool.get('ir.header_img')
@@ -74,11 +74,11 @@
7474
75 head = header_obj.browse(self.cursor, self.uid, header_img_id)75 head = header_obj.browse(self.cursor, self.uid, header_img_id)
76 return (head.img, head.type)76 return (head.img, head.type)
77 77
78 def embed_logo_by_name(self, name, width=0, height=0) :78 def embed_logo_by_name(self, name, width=0, height=0, unit="px") :
79 """Return HTML embedded logo by name"""79 """Return HTML embedded logo by name"""
80 img, type = self.get_logo_by_name(name)80 img, type = self.get_logo_by_name(name)
81 return self.embed_image(type, img, width, height)81 return self.embed_image(type, img, width, height, unit)
82 82
8383
84# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:84# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: