Odoo Help

0

How to display images for non-admin website users ?

By
PY
on 7/1/15, 5:53 AM 1,117 views

Hi !

In my website, I declared a field like this

<template id="transporter_image" inherit_id="website_sale.payment">
<xpath expr="//div[@id='delivery_carrier']//input" position="after">
<span itemprop="image" t-field="delivery.partner_id.image"
t-field-options='{"widget": "image"}' style="display: inline-block;"/>
</xpath>
</template>

As Admin, this renders like

<span itemprop="image" style="display: inline-block;" data-oe-id="864"
data-oe-source-id="841" data-oe-xpath="/data/xpath/span"
data-oe-model="ir.ui.view" data-oe-field="arch" data-oe-type="image"
data-oe-expression="delivery.partner_id.image" data-oe-translate="0">
<img class="img img-responsive" src="/website/image/res.partner/6_8994a20/image" style="">
</span>

As an external user, it looks like this:

<span itemprop="image" style="display: inline-block;">
<img class="img img-responsive" src="/website/image/res.partner/6_8994a20/image" style="">
</span>

and thus, the image is not being rendered.


How to solve this ?

1
PY
On 7/1/15, 8:34 AM

Workaround that does the job:

<template id="transporter_image" inherit_id="website_sale.payment">
<xpath expr="//div[@id='delivery_carrier']//input" position="after">
<img itemprop="image" class="img img-responsive" style="display: inline-block;"
t-att-src="'data:image/png;base64,' + delivery.partner_id.image"/>
</xpath>
</template>

I will use it until I find a better alternative.

Good answer

shameem@iWesabe
on 8/31/16, 6:59 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 7/1/15, 5:53 AM
Seen: 1117 times
Last updated: 7/1/15, 8:34 AM