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

Proposed by Yannick Vaucher @ Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/6.0-webkit_report-image_helper-20120719
Merge into: lp:openobject-addons/6.0
Diff against target: 52 lines (+11/-11)
1 file modified
report_webkit/report_helper.py (+11/-11)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/6.0-webkit_report-image_helper-20120719
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+115764@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

5296. 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/report_helper.py'
2--- report_webkit/report_helper.py 2011-03-14 17:14:29 +0000
3+++ report_webkit/report_helper.py 2012-07-19 15:20:27 +0000
4@@ -39,26 +39,26 @@
5 self.uid = uid
6 self.pool = pooler.get_pool(self.cursor.dbname)
7 self.report_id = report_id
8-
9- def embed_image(self, type, img, width=0, height=0) :
10+
11+ def embed_image(self, type, img, width=0, height=0, unit="px") :
12 "Transform a DB image into an embedded HTML image"
13
14 if width :
15- width = 'width="%spx"'%(width)
16+ width = 'width: %s%s;'%(width, unit)
17 else :
18 width = ' '
19 if height :
20- height = 'height="%spx"'%(height)
21+ height = 'height: %s%s;'%(height, unit)
22 else :
23 height = ' '
24- toreturn = '<img %s %s src="data:image/%s;base64,%s" />'%(
25+ toreturn = '<img style="%s%s" src="data:image/%s;base64,%s" />'%(
26 width,
27 height,
28 type,
29 str(img))
30 return toreturn
31-
32-
33+
34+
35 def get_logo_by_name(self, name):
36 """Return logo by name"""
37 header_obj = self.pool.get('ir.header_img')
38@@ -74,9 +74,9 @@
39
40 head = header_obj.browse(self.cursor, self.uid, header_img_id)
41 return (head.img, head.type)
42-
43- def embed_logo_by_name(self, name, width=0, height=0) :
44+
45+ def embed_logo_by_name(self, name, width=0, height=0, unit="px") :
46 """Return HTML embedded logo by name"""
47 img, type = self.get_logo_by_name(name)
48- return self.embed_image(type, img, width, height)
49-
50\ No newline at end of file
51+ return self.embed_image(type, img, width, height, unit)
52+