[FIX] - attachment_preview: Migrated the module to 9.0 version and fixed some errors displaying the attachments files.

This commit is contained in:
Carlos Quiros 2016-10-19 13:52:21 -06:00
parent 32874e128b
commit 54860e01e1

View File

@ -31,14 +31,14 @@ odoo.define('attachment_preview', function (require) {
var _t = core._t; var _t = core._t;
function show_preview(attachment_id, attachment_url, attachment_extension, attachment_title) { function show_preview(attachment_id, attachment_url, attachment_extension, attachment_title) {
var url = (window.location.origin || '') + var url = ((window.location.origin || '') +
'/attachment_preview/static/lib/ViewerJS/index.html' + '/attachment_preview/static/lib/ViewerJS/index.html' +
'?type=' + encodeURIComponent(attachment_extension) + '?type=' + encodeURIComponent(attachment_extension) +
'&title=' + encodeURIComponent(attachment_title) + '&title=' + encodeURIComponent(attachment_title) +
'#' + '#' +
attachment_url.replace(window.location.origin, '') attachment_url.replace(window.location.origin, ''));
window.open(url); window.open(url);
}; }
function can_preview(extension) { function can_preview(extension) {
return jQuery.inArray( return jQuery.inArray(
@ -47,7 +47,7 @@ odoo.define('attachment_preview', function (require) {
'odt', 'odp', 'ods', 'fodt', 'pdf', 'ott', 'fodp', 'otp', 'odt', 'odp', 'ods', 'fodt', 'pdf', 'ott', 'fodp', 'otp',
'fods', 'ots' 'fods', 'ots'
]) > -1; ]) > -1;
}; }
Sidebar.include({ Sidebar.include({
on_attachments_loaded: function(attachments) { on_attachments_loaded: function(attachments) {
@ -104,8 +104,8 @@ odoo.define('attachment_preview', function (require) {
_(extensions).each(function(extension, id) _(extensions).each(function(extension, id)
{ {
var $element = jQuery( var $element = jQuery(
'span.oe_sidebar_attachment_preview[data-id="' 'span.oe_sidebar_attachment_preview[data-id="'+
+ id + '"]'); id + '"]');
if(can_preview(extension[0])) if(can_preview(extension[0]))
{ {
$element.attr('data-extension', extension[0]); $element.attr('data-extension', extension[0]);
@ -238,7 +238,7 @@ odoo.define('attachment_preview', function (require) {
else else
{ {
this.$('.oe_binary_preview').remove(); this.$('.oe_binary_preview').remove();
}; }
}, },
}); });
}); });