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

[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

[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
=== modified file 'report_webkit/report_helper.py'
--- report_webkit/report_helper.py 2013-03-18 14:37:26 +0000
+++ report_webkit/report_helper.py 2013-03-18 14:37:26 +0000
@@ -4,7 +4,8 @@
4# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com) 4# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com)
5# All Right Reserved5# All Right Reserved
6#6#
7# Author : Nicolas Bessi (Camptocamp)7# Authors : Nicolas Bessi (Camptocamp)
8# Yannick Vaucher (Camptocamp)
8#9#
9# WARNING: This program as such is intended to be used by professional10# WARNING: This program as such is intended to be used by professional
10# programmers who take the whole responsability of assessing all potential11# programmers who take the whole responsability of assessing all potential
@@ -39,19 +40,19 @@
39 self.uid = uid40 self.uid = uid
40 self.pool = pooler.get_pool(self.cursor.dbname)41 self.pool = pooler.get_pool(self.cursor.dbname)
41 self.report_id = report_id42 self.report_id = report_id
42 43
43 def embed_image(self, type, img, width=0, height=0) :44 def embed_image(self, type, img, width=0, height=0, unit="px"):
44 "Transform a DB image into an embedded HTML image"45 "Transform a DB image into an embedded HTML image"
4546
46 if width :47 if width :
47 width = 'width="%spx"'%(width)48 width = 'width: %s%s;'%(width, unit)
48 else :49 else :
49 width = ' '50 width = ' '
50 if height :51 if height :
51 height = 'height="%spx"'%(height)52 height = 'height: %s%s;'%(height, unit)
52 else :53 else :
53 height = ' '54 height = ' '
54 toreturn = '<img %s %s src="data:image/%s;base64,%s" />'%(55 toreturn = '<img style="%s%s" src="data:image/%s;base64,%s" />'%(
55 width,56 width,
56 height,57 height,
57 type, 58 type,
@@ -76,10 +77,10 @@
76 head = header_obj.browse(self.cursor, self.uid, header_img_id)77 head = header_obj.browse(self.cursor, self.uid, header_img_id)
77 return (head.img, head.type)78 return (head.img, head.type)
78 79
79 def embed_logo_by_name(self, name, width=0, height=0, company_id=None):80 def embed_logo_by_name(self, name, width=0, height=0, unit="px", company_id=None):
80 """Return HTML embedded logo by name"""81 """Return HTML embedded logo by name"""
81 img, type = self.get_logo_by_name(name, company_id=company_id)82 img, type = self.get_logo_by_name(name, company_id=company_id)
82 return self.embed_image(type, img, width, height)83 return self.embed_image(type, img, width, height, unit)
83 84
8485
85# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:86# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: