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
=== modified file 'report_webkit/report_helper.py'
--- report_webkit/report_helper.py 2011-03-14 17:14:29 +0000
+++ report_webkit/report_helper.py 2012-07-19 15:20:27 +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,9 +74,9 @@
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)
82
83\ No newline at end of file81\ No newline at end of file
82 return self.embed_image(type, img, width, height, unit)
83