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

Proposed by Yannick Vaucher @ Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/7.0-webkit_report-image_helper-20130318
Merge into: lp:openobject-addons/7.0
Prerequisite: lp:~camptocamp/openobject-addons/7.0-fix-multi-comp-webkit-header
Diff against target: 51 lines (+9/-8)
1 file modified
report_webkit/report_helper.py (+9/-8)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/7.0-webkit_report-image_helper-20130318
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+153822@code.launchpad.net

This proposal supersedes a proposal from 2013-03-18.

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

8798. 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

8797. By Nicolas Bessi - Camptocamp on 2013-03-05

[FIX] report_webkit embed_logo_by_name multi-company support

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-03-18 14:37:26 +0000
3+++ report_webkit/report_helper.py 2013-03-18 14:37:26 +0000
4@@ -4,7 +4,8 @@
5 # Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com)
6 # All Right Reserved
7 #
8-# Author : Nicolas Bessi (Camptocamp)
9+# Authors : Nicolas Bessi (Camptocamp)
10+# Yannick Vaucher (Camptocamp)
11 #
12 # WARNING: This program as such is intended to be used by professional
13 # programmers who take the whole responsability of assessing all potential
14@@ -39,19 +40,19 @@
15 self.uid = uid
16 self.pool = pooler.get_pool(self.cursor.dbname)
17 self.report_id = report_id
18-
19- def embed_image(self, type, img, width=0, height=0) :
20+
21+ def embed_image(self, type, img, width=0, height=0, unit="px"):
22 "Transform a DB image into an embedded HTML image"
23
24 if width :
25- width = 'width="%spx"'%(width)
26+ width = 'width: %s%s;'%(width, unit)
27 else :
28 width = ' '
29 if height :
30- height = 'height="%spx"'%(height)
31+ height = 'height: %s%s;'%(height, unit)
32 else :
33 height = ' '
34- toreturn = '<img %s %s src="data:image/%s;base64,%s" />'%(
35+ toreturn = '<img style="%s%s" src="data:image/%s;base64,%s" />'%(
36 width,
37 height,
38 type,
39@@ -76,10 +77,10 @@
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, company_id=None):
44+ def embed_logo_by_name(self, name, width=0, height=0, unit="px", company_id=None):
45 """Return HTML embedded logo by name"""
46 img, type = self.get_logo_by_name(name, company_id=company_id)
47- return self.embed_image(type, img, width, height)
48+ return self.embed_image(type, img, width, height, unit)
49
50
51 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: