Merge lp:~camptocamp/openobject-addons/trunk-webkit_report-image_helper-20130318 into lp:openobject-addons

Proposed by Yannick Vaucher @ Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/trunk-webkit_report-image_helper-20130318
Merge into: lp:openobject-addons
Diff against target: 70 lines (+15/-16)
1 file modified
report_webkit/report_helper.py (+15/-16)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/trunk-webkit_report-image_helper-20130318
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+153781@code.launchpad.net

Description of the change

In image helper, fix construction of image tag and improve it to let use other units than px (better to use mm and cm for reports)

This MP is a forward port of the following:
https://code.launchpad.net/~camptocamp/openobject-addons/6.0-webkit_report-image_helper-20120719
https://code.launchpad.net/~camptocamp/openobject-addons/6.1-webkit_report-image_helper-20120719

To post a comment you must log in.

Unmerged revisions

8632. By Yannick Vaucher @ Camptocamp on 2013-03-18

[FIX] report_webkit - 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 2013-02-25 16:06:50 +0000
3+++ report_webkit/report_helper.py 2013-03-18 12:59:33 +0000
4@@ -40,32 +40,32 @@
5 self.pool = pooler.get_pool(self.cursor.dbname)
6 self.report_id = report_id
7 self.context = context
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+ type,
30 str(img))
31 return toreturn
32-
33-
34+
35+
36 def get_logo_by_name(self, name):
37 """Return logo by name"""
38 header_obj = self.pool.get('ir.header_img')
39 header_img_id = header_obj.search(
40- self.cursor,
41- self.uid,
42+ self.cursor,
43+ self.uid,
44 [('name','=',name)]
45 )
46 if not header_img_id :
47@@ -75,18 +75,17 @@
48
49 head = header_obj.browse(self.cursor, self.uid, header_img_id)
50 return (head.img, head.type)
51-
52- def embed_logo_by_name(self, name, width=0, height=0):
53+
54+ def embed_logo_by_name(self, name, width=0, height=0, unit="px"):
55 """Return HTML embedded logo by name"""
56 img, type = self.get_logo_by_name(name)
57- return self.embed_image(type, img, width, height)
58+ return self.embed_image(type, img, width, height, unit)
59
60- def embed_company_logo(self, width=0, height=0):
61+ def embed_company_logo(self, width=0, height=0, unit="px"):
62 cr, uid, context = self.cursor, self.uid, self.context
63 my_user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
64 logo = my_user.company_id.logo_web
65- return self.embed_image("png", logo, width, height)
66+ return self.embed_image("png", logo, width, height, unit)
67
68-
69
70 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches

to all changes: