I would like to create a href link in Odoo pointing to external file based on field value .....
for example: <field name="item_id"/> value of this field is 123456789012
at the end I would like to have a link for example: 'href="localhost/images/123456789012.png"'
and then add widget image to display selected picture .....
Is it possible ? If so, how can i do it ?
(easiest way)
Create def and then append 'link','.ext' ?
How should it look like ?
I searched on internet but I couldn't find any examples :(
So far i tried to use (modified) widget="html" and it create a link but because is already one widget added i can't add another one :)
so i need create a link then add widget="image" or custom widget to show image in form :)
I've managed to do it partially, it shows me a placeholder from the same location but it won't display a selected image ;(
........
Ahahaha I got it, it works but .... silly me python generates incorrectly a string :)
at the end i'm getting a string which looks like this: "(u'360651041248', '.jpg')" how can I get rid of unwanted chars to get only '360651041248.jpg' ?
I managed to clear string and now is perfect but somehow Odoo instead /web/src/img/myimages/ trying to find an image directly in //localhost:8069/image.jpg
What the hell ?
Why ?
Everything seems to be ok but it won't work ...
<pre>
instance.web.form.FieldPCTable = instance.web.form.FieldBinary.extend({
template: 'FieldBinaryImage',
placeholder: "/web/static/src/img/pctables/placeholder.jpg", ### here is the link to the placeholder image which works perfectly
render_value: function() {
var self = this;
var url;
if (this.get('value') && !instance.web.form.is_bin_size(this.get('value'))) {
url = this.get('value');
} else if (this.get('value')) {
var id = JSON.stringify(this.view.datarecord.id || null);
var field = this.name;
if (this.options.preview_image)
field = this.options.preview_image;
url = 'data:image/png;base64,' + this.session.url('/web/static/src/img/pctables/', { ### here is a folder where image is located
model: this.view.dataset.model,
id: id,
field: field,
t: (new Date().getTime()),
});
and at the end I'm getting http://localhost:8069/image.jpg ..... WHY !?!?!?!
I think I found the culprit ;)
Can you update the answer if you solved it?