[FIX] Third part of bug#1077858 : Error in list view when displaying non saved o2m item with binary field
lp bug: https://launchpad.net/bugs/1077858 fixed bzr revid: fme@openerp.com-20121112172541-n312hzvsqcr78jeh
This commit is contained in:
parent
cd4c3c61ff
commit
40734fc4c4
|
@ -2163,20 +2163,26 @@ instance.web.list.Binary = instance.web.list.Column.extend({
|
|||
*/
|
||||
_format: function (row_data, options) {
|
||||
var text = _t("Download");
|
||||
var download_url = _.str.sprintf(
|
||||
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 = _.str.sprintf(
|
||||
'/web/binary/saveas?session_id=%s&model=%s&field=%s&id=%d',
|
||||
instance.session.session_id, options.model, this.id, options.id);
|
||||
if (this.filename) {
|
||||
download_url += '&filename_field=' + this.filename;
|
||||
if (row_data[this.filename]) {
|
||||
text = _.str.sprintf(_t("Download \"%s\""), instance.web.format_value(
|
||||
row_data[this.filename].value, {type: 'char'}));
|
||||
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(row_data[this.id].value),
|
||||
size: instance.web.binary_to_binsize(value),
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue