Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions attachment_preview/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,30 @@ Installation
============

For filetype recognition, you'll get the best results by installing
``python-magic``::

sudo apt-get install python-magic
``python-magic``:: sudo apt-get install python-magic or pip install file-magic

Usage
=====

The module adds a little print preview icon right of download links for
attachments or binary fields.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/118/8.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9.0


For further information, please visit:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this part


* https://www.odoo.com/forum/help-1

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Expand All @@ -31,6 +45,8 @@ Contributors
------------

* Holger Brunn <hbrunn@therp.nl>
* Carlos Quirós <carlos.quiros@clearcorp.co.cr>
* Glen Sojo <glen.sojo@clearcorp.co.cr>

Maintainer
----------
Expand Down
4 changes: 2 additions & 2 deletions attachment_preview/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
##############################################################################
{
"name": "Preview attachments",
"version": "8.0.1.1.0",
"version": "9.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"complexity": "normal",
Expand All @@ -38,7 +38,7 @@
"test": [
],
"auto_install": False,
'installable': False,
'installable': True,
"application": False,
"external_dependencies": {
'python': [],
Expand Down
28 changes: 28 additions & 0 deletions attachment_preview/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attachment_preview
#
# Translators:
# Rudolf Schnapka <rs@techno-flex.de>, 2015
msgid ""
msgstr ""
"Project-Id-Version: knowledge (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-12-08 08:32+0000\n"
"PO-Revision-Date: 2015-11-25 09:41+0000\n"
"Last-Translator: Rudolf Schnapka <rs@techno-flex.de>\n"
"Language-Team: German (http://www.transifex.com/oca/OCA-knowledge-8-0/language/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:184
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:226
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:228
#, python-format
msgid "Preview %s"
msgstr "Vorschau %s"
28 changes: 28 additions & 0 deletions attachment_preview/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attachment_preview
#
# Translators:
# Antonio Trueba, 2016
msgid ""
msgstr ""
"Project-Id-Version: knowledge (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-12-19 10:18+0000\n"
"PO-Revision-Date: 2016-01-25 18:15+0000\n"
"Last-Translator: Antonio Trueba\n"
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-knowledge-8-0/language/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:184
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:226
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:228
#, python-format
msgid "Preview %s"
msgstr "Previsualizar %s"
28 changes: 28 additions & 0 deletions attachment_preview/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attachment_preview
#
# Translators:
# Paolo Valier, 2016
msgid ""
msgstr ""
"Project-Id-Version: knowledge (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-03-05 11:50+0000\n"
"PO-Revision-Date: 2016-03-13 16:56+0000\n"
"Last-Translator: Paolo Valier\n"
"Language-Team: Italian (http://www.transifex.com/oca/OCA-knowledge-8-0/language/it/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: it\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:184
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:226
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:228
#, python-format
msgid "Preview %s"
msgstr "Anteprima %s"
24 changes: 13 additions & 11 deletions attachment_preview/i18n/nl.po
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attachment_preview
#
# * attachment_preview
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Project-Id-Version: knowledge (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-15 11:04+0000\n"
"PO-Revision-Date: 2015-08-03 13:36+0200\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"POT-Creation-Date: 2015-12-08 08:32+0000\n"
"PO-Revision-Date: 2015-11-07 12:44+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: Dutch (http://www.transifex.com/oca/OCA-knowledge-8-0/language/nl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"Content-Transfer-Encoding: \n"
"Language: nl\n"
"X-Generator: Poedit 1.8.2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: attachment_preview
#. openerp-web
#: code:multiple:42
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:184
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:226
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:228
#, python-format
msgid "Preview %s"
msgstr "Voorbeeld %s"
28 changes: 28 additions & 0 deletions attachment_preview/i18n/pt_PT.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attachment_preview
#
# Translators:
# Pedro Castro Silva <pedrocs@sossia.pt>, 2016
msgid ""
msgstr ""
"Project-Id-Version: knowledge (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-05-07 16:07+0000\n"
"PO-Revision-Date: 2016-05-22 22:19+0000\n"
"Last-Translator: Pedro Castro Silva <pedrocs@sossia.pt>\n"
"Language-Team: Portuguese (Portugal) (http://www.transifex.com/oca/OCA-knowledge-8-0/language/pt_PT/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: pt_PT\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:184
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:226
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:228
#, python-format
msgid "Preview %s"
msgstr "Antever %s"
24 changes: 13 additions & 11 deletions attachment_preview/i18n/sl.po
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attachment_preview
#
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015.
# * attachment_preview
#
# Translators:
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Project-Id-Version: knowledge (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-15 11:04+0000\n"
"PO-Revision-Date: 2015-08-03 13:36+0200\n"
"POT-Creation-Date: 2015-12-08 08:32+0000\n"
"PO-Revision-Date: 2015-11-08 05:36+0000\n"
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
"Language-Team: Slovenian <translate@matmoz.si>\n"
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-knowledge-8-0/language/sl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"Content-Transfer-Encoding: \n"
"Language: sl\n"
"X-Generator: Poedit 1.8.2\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"

#. module: attachment_preview
#. openerp-web
#: code:multiple:42
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:184
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:226
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:228
#, python-format
msgid "Preview %s"
msgstr "Predogled %s"
10 changes: 6 additions & 4 deletions attachment_preview/model/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
import os.path
import mimetypes
import base64
from openerp.osv.orm import Model
from openerp import models


class IrAttachment(Model):
class IrAttachment(models.Model):

_inherit = 'ir.attachment'

def get_binary_extension(
Expand Down Expand Up @@ -59,8 +60,9 @@ def get_binary_extension(
'data:;base64,' + this[binary_field], strict=False)
extension = mimetypes.guess_extension(
mimetype.split(';')[0], strict=False)

result[this.id] = (extension or '').lstrip('.').lower()
docdata = {1: this[binary_field],
0: (extension or '').lstrip('.').lower()}
result[this.id] = docdata
return result if isinstance(ids, collections.Iterable) else result[ids]

def get_attachment_extension(self, cr, uid, ids, context=None):
Expand Down
29 changes: 16 additions & 13 deletions attachment_preview/static/lib/ViewerJS/compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,20 +447,10 @@ if (typeof PDFJS === 'undefined') {

// Checks if navigator.language is supported
(function checkNavigatorLanguage() {
if ('language' in navigator &&
/^[a-z]+(-[A-Z]+)?$/.test(navigator.language)) {
if ('language' in navigator) {
return;
}
function formatLocale(locale) {
var split = locale.split(/[-_]/);
split[0] = split[0].toLowerCase();
if (split.length > 1) {
split[1] = split[1].toUpperCase();
}
return split.join('-');
}
var language = navigator.language || navigator.userLanguage || 'en-US';
PDFJS.locale = formatLocale(language);
PDFJS.locale = navigator.userLanguage || 'en-US';
})();

(function checkRangeRequests() {
Expand All @@ -479,7 +469,10 @@ if (typeof PDFJS === 'undefined') {
var regex = /Android\s[0-2][^\d]/;
var isOldAndroid = regex.test(navigator.userAgent);

if (isSafari || isOldAndroid) {
// Range requests are broken in Chrome 39 and 40, https://crbug.com/442318
var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(navigator.userAgent);

if (isSafari || isOldAndroid || isChromeWithRangeBug) {
PDFJS.disableRange = true;
PDFJS.disableStream = true;
}
Expand Down Expand Up @@ -572,3 +565,13 @@ if (typeof PDFJS === 'undefined') {
PDFJS.maxCanvasPixels = 5242880;
}
})();

// Disable fullscreen support for certain problematic configurations.
// Support: IE11+ (when embedded).
(function checkFullscreenSupport() {
var isEmbeddedIE = (navigator.userAgent.indexOf('Trident') >= 0 &&
window.parent !== window);
if (isEmbeddedIE) {
PDFJS.disableFullscreen = true;
}
})();
62 changes: 30 additions & 32 deletions attachment_preview/static/lib/ViewerJS/index.html

Large diffs are not rendered by default.

Loading