|
@ -1,6 +1,7 @@ |
|
|
/* |
|
|
/* |
|
|
OpenERP, Open Source Management Solution |
|
|
OpenERP, Open Source Management Solution |
|
|
This module copyright (C) 2014 Therp BV (<http://therp.nl>).
|
|
|
|
|
|
|
|
|
This module copyright (C) 2014 Therp BV (<http://therp.nl>)
|
|
|
|
|
|
(C) 2013 Marcel van der Boom <marcel@hsdev.com> |
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify |
|
|
This program is free software: you can redistribute it and/or modify |
|
|
it under the terms of the GNU Affero General Public License as |
|
|
it under the terms of the GNU Affero General Public License as |
|
@ -18,14 +19,29 @@ |
|
|
|
|
|
|
|
|
openerp.web_tree_image = function (instance) { |
|
|
openerp.web_tree_image = function (instance) { |
|
|
instance.web.list.Image = instance.web.list.Column.extend({ |
|
|
instance.web.list.Image = instance.web.list.Column.extend({ |
|
|
/* Return an image tag */ |
|
|
|
|
|
format: function (row_data, options) { |
|
|
format: function (row_data, options) { |
|
|
if (!row_data[this.id] || !row_data[this.id].value) { return ''; } |
|
|
|
|
|
var src; |
|
|
|
|
|
if (!/\//.test(row_data[this.id].value)) { |
|
|
|
|
|
src = '/web/static/src/img/icons/' + row_data[this.id].value + '.png'; |
|
|
|
|
|
|
|
|
/* Return a valid img tag. For image fields, test if the |
|
|
|
|
|
field's value contains just the binary size and retrieve |
|
|
|
|
|
the image from the dedicated controller in that case. |
|
|
|
|
|
Otherwise, assume a character field containing either a |
|
|
|
|
|
stock Odoo icon name without path or extension or a fully |
|
|
|
|
|
fledged location or data url */ |
|
|
|
|
|
if (!row_data[this.id] || !row_data[this.id].value) { |
|
|
|
|
|
return ''; |
|
|
|
|
|
} |
|
|
|
|
|
var value = row_data[this.id].value, src; |
|
|
|
|
|
if (this.type === 'binary') { |
|
|
|
|
|
if (value && value.substr(0, 10).indexOf(' ') === -1) { |
|
|
|
|
|
src = "data:image/png;base64," + value; |
|
|
|
|
|
} else { |
|
|
|
|
|
src = instance.session.url('/web/binary/image', {model: options.model, field: this.id, id: options.id}); |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
src = row_data[this.id].value; |
|
|
|
|
|
|
|
|
if (!/\//.test(row_data[this.id].value)) { |
|
|
|
|
|
src = '/web/static/src/img/icons/' + row_data[this.id].value + '.png'; |
|
|
|
|
|
} else { |
|
|
|
|
|
src = row_data[this.id].value; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return instance.web.qweb.render('ListView.row.image', {widget: this, src: src}); |
|
|
return instance.web.qweb.render('ListView.row.image', {widget: this, src: src}); |
|
|
} |
|
|
} |
|
|