Odoo Help


How to add function into file view_tree.js in openerp\addons\web\static\src\js\view_tree.js

Huynh Huu Tho
on 2/13/14, 11:12 PM 1,341 views

Hi all.

In view_list.js file, there is "instance.web.list.Binary = instance.web.list.Column.extend" function.:

instance.web.list.Binary = instance.web.list.Column.extend({

_format: function (row_data, options) {
    var text = _t("Download");
    var value = row_data[this.id].value;
    var download_url;
    if (value && value.substr(0, 10).indexOf(' ') == -1) {
        download_url = "data:application/octet-stream;base64," + value;
    } else {
        download_url = instance.session.url('/web/binary/saveas', {model: options.model, field: this.id, id: options.id});
        if (this.filename) {
            download_url += '&filename_field=' + this.filename;
    if (this.filename && row_data[this.filename]) {
        text = _.str.sprintf(_t("Download \"%s\""), instance.web.format_value(
                row_data[this.filename].value, {type: 'char'}));
    return _.template('<a href="<%-href%>"><%-text%></a> (<%-size%>)', {
        text: text,
        href: download_url,
        size: instance.web.binary_to_binsize(value),


I want to copy that function to view_tree.js file but it is not working.

I want to coppy function because function convert field binary to image.

In view_tree.js not convert field binary.


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.


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

0 follower(s)


Asked: 2/13/14, 11:12 PM
Seen: 1341 times
Last updated: 3/16/15, 8:10 AM