Odoo Help

Welcome!

This community 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.

0

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

By
Huynh Huu Tho
on 2/13/14, 11:12 PM 1,070 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.

Thank

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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