[FIX] ir_actions_report: Render correctly the base64 images in P3
Purpose ======= In python2 a binary field value is retrieved as a string. Example: company_id.logo = u'xyz' In python3 a binary field value is retrieved as a binary. Example: company_id.logo = b'xyz' When trying to render an image on a template, we should pass a stringified version of it. Specification ============= Pass the method to_text in the template rendering context and use it.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<div t-field="o.event_id.event_logo"/>
|
||||
</t>
|
||||
<span t-if="not o.event_id.event_logo and o.event_id.organizer_id.company_id.logo_web and o.event_id.organizer_id.is_company">
|
||||
<img t-att-src="'data:image/png;base64,%s' % o.event_id.organizer_id.company_id.logo_web" style="max-height:1cm; max-width:4cm;"/>
|
||||
<img t-att-src="'data:image/png;base64,%s' % to_text(o.event_id.organizer_id.company_id.logo_web)" style="max-height:1cm; max-width:4cm;"/>
|
||||
</span>
|
||||
<h5 t-field="o.event_id.name"/>
|
||||
<h5>( <i class="fa fa-clock-o"></i> <span itemprop="startDate" t-field="o.event_id.date_begin" t-options='{"hide_seconds": True}'> </span> <i>to</i> <span itemprop="endDate" t-field="o.event_id.date_end" t-options='{"hide_seconds": True}'> </span> )</h5>
|
||||
@@ -65,7 +65,7 @@
|
||||
<div class="col-xs-12">
|
||||
<span t-if="event.organizer_id.is_company and event.organizer_id.company_id.logo_web">
|
||||
<div t-field="event.event_logo">
|
||||
<img t-att-src="'data:image/png;base64,%s' % event.organizer_id.company_id.logo_web" style="max-height:1cm; max-width:4cm;"/>
|
||||
<img t-att-src="'data:image/png;base64,%s' % to_text(event.organizer_id.company_id.logo_web)" style="max-height:1cm; max-width:4cm;"/>
|
||||
</div>
|
||||
</span>
|
||||
<h4 t-field="event.name"/>
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
<table style="width:77pt; height:150pt">
|
||||
<tr style="height:30%">
|
||||
<td align="center" valign="center">
|
||||
<img t-if="employee.company_id and employee.company_id.logo" t-att-src="'data:image/png;base64,%s' % (employee.company_id.logo,)" style="max-height:45pt;max-width:90%" alt="Company Logo"/>
|
||||
<img t-if="employee.company_id and employee.company_id.logo" t-att-src="'data:image/png;base64,%s' % to_text(employee.company_id.logo)" style="max-height:45pt;max-width:90%" alt="Company Logo"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="height:70%;">
|
||||
<td align="center" valign="center">
|
||||
<img t-if="employee.image" t-att-src="'data:image/png;base64,%s' % (employee.image,)" style="max-height:85pt;max-width:90%" alt="Employee Image"/>
|
||||
<img t-if="employee.image" t-att-src="'data:image/png;base64,%s' % to_text(employee.image)" style="max-height:85pt;max-width:90%" alt="Employee Image"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<img class="image" t-att-src="'data:image/png;base64,%s' % res_company.logo" style="border:auto;"/>
|
||||
<img class="image" t-att-src="'data:image/png;base64,%s' % to_text(res_company.logo)" style="border:auto;"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<img class="image" t-att-src="'data:image/png;base64,%s' % res_company.logo" style="border:auto;"/>
|
||||
<img class="image" t-att-src="'data:image/png;base64,%s' % to_text(res_company.logo)" style="border:auto;"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
<div class="pull-right">
|
||||
<h3 class="mt0 text-right" t-field="company.report_header"/>
|
||||
</div>
|
||||
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" class="pull-left"/>
|
||||
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % to_text(company.logo)" class="pull-left"/>
|
||||
<div class="pull-left company_address">
|
||||
<div>
|
||||
<strong t-field="company.partner_id.name"/>
|
||||
@@ -180,7 +180,7 @@
|
||||
<div class="header o_boxed_header">
|
||||
<div class="row mb8">
|
||||
<div class="col-xs-6">
|
||||
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo"/>
|
||||
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % to_text(company.logo)"/>
|
||||
</div>
|
||||
<div class="col-xs-6 text-right mb4">
|
||||
<h4 class="mt0" t-field="company.report_header"/>
|
||||
@@ -216,7 +216,7 @@
|
||||
<div class="header o_clean_header">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo"/>
|
||||
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % to_text(company.logo)"/>
|
||||
</div>
|
||||
<div class="col-xs-5 col-xs-offset-1" name="company_address">
|
||||
<ul class="list-unstyled">
|
||||
@@ -259,7 +259,7 @@
|
||||
<div class="header">
|
||||
<div class="row">
|
||||
<div class="col-xs-3 mb4">
|
||||
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height: 45px;"/>
|
||||
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % to_text(company.logo)" style="max-height: 45px;"/>
|
||||
</div>
|
||||
<div class="col-xs-9 text-right" style="margin-top:22px;" t-field="company.report_header" name="moto"/>
|
||||
</div>
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
<t t-foreach="team" t-as="user" class="media">
|
||||
<div class="media">
|
||||
<div class="pull-left" t-if='user.image_small'>
|
||||
<img t-att-src="user.image_small and ('data:image/png;base64,' + user.image_small) or '/web/static/src/img/placeholder.png'"
|
||||
<img t-att-src="user.image_small and ('data:image/png;base64,' + to_text(user.image_small)) or '/web/static/src/img/placeholder.png'"
|
||||
class="img-rounded" t-att-alt="user.name"/>
|
||||
</div>
|
||||
<div class="media-body">
|
||||
@@ -159,7 +159,7 @@
|
||||
<t t-foreach="channels" t-as="channel">
|
||||
<div class="media">
|
||||
<a class="pull-left" t-attf-href="/livechat/channel/#{ slug(channel)}">
|
||||
<img t-att-src="channel.image_small and ('data:image/png;base64,' + channel.image_small) or '/web/static/src/img/placeholder.png'" t-att-alt="channel.name" />
|
||||
<img t-att-src="channel.image_small and ('data:image/png;base64,' + to_text(channel.image_small)) or '/web/static/src/img/placeholder.png'" t-att-alt="channel.name" />
|
||||
</a>
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading"><t t-esc="channel.name"/></h4>
|
||||
|
||||
@@ -12,6 +12,7 @@ import time
|
||||
import base64
|
||||
import io
|
||||
import logging
|
||||
import odoo
|
||||
import os
|
||||
import lxml.html
|
||||
import tempfile
|
||||
@@ -465,7 +466,8 @@ class IrActionsReport(models.Model):
|
||||
user=user,
|
||||
res_company=user.company_id,
|
||||
website=website,
|
||||
web_base_url=self.env['ir.config_parameter'].sudo().get_param('web.base.url', default='')
|
||||
web_base_url=self.env['ir.config_parameter'].sudo().get_param('web.base.url', default=''),
|
||||
to_text=odoo.tools.pycompat.to_text,
|
||||
)
|
||||
return view_obj.render_template(template, values)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user