[MIG] attachment_preview: Migration to 12.0

This commit is contained in:
mreficent 2019-03-19 18:40:24 +01:00
parent 0360c69f79
commit f670e5358f
15 changed files with 45 additions and 48 deletions

View File

@ -1,6 +1,6 @@
=================== ==================
Preview attachments Attachment Preview
=================== ==================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
@ -14,18 +14,18 @@ Preview attachments
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
:target: https://github.com/OCA/knowledge/tree/11.0/attachment_preview :target: https://github.com/OCA/knowledge/tree/12.0/attachment_preview
:alt: OCA/knowledge :alt: OCA/knowledge
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/knowledge-11-0/knowledge-11-0-attachment_preview :target: https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-attachment_preview
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/118/11.0 :target: https://runbot.odoo-community.org/runbot/118/12.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
This addon allows to preview attachments supported by http://viewerjs.org. This module allows to preview attachments supported by http://viewerjs.org.
Currently, that's most Libreoffice files and PDFs. Currently, that's most Libreoffice files and PDFs.
@ -44,7 +44,7 @@ Installation
For filetype recognition, you'll get the best results by installing For filetype recognition, you'll get the best results by installing
``python-magic``: ``python-magic``:
sudo apt-get install python-magic sudo apt-get install python3-magic
Usage Usage
===== =====
@ -64,7 +64,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_. 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. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -86,8 +86,8 @@ Contributors
Other credits Other credits
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
Addon icon Module icon
---------- -----------
* courtesy of http://commons.wikimedia.org/wiki/Crystal_Clear * courtesy of http://commons.wikimedia.org/wiki/Crystal_Clear
@ -104,6 +104,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/11.0/attachment_preview>`_ project on GitHub. This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/12.0/attachment_preview>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1,4 +1,3 @@
# Copyright 2014 Therp BV (<http://therp.nl>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models from . import models

View File

@ -2,8 +2,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "Preview attachments", "name": "Attachment Preview",
"version": "11.0.1.3.0", "version": "12.0.1.0.0",
"author": "Therp BV," "author": "Therp BV,"
"Onestein," "Onestein,"
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",

View File

@ -1,4 +1,3 @@
# Copyright 2014 Therp BV (<http://therp.nl>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import ir_attachment from . import ir_attachment

View File

@ -46,6 +46,7 @@ class IrAttachment(models.Model):
continue continue
try: try:
import magic import magic
magic = magic.Magic(magic.flags.MAGIC_NONE)
if model == self._name and binary_field == 'datas'\ if model == self._name and binary_field == 'datas'\
and this.store_fname: and this.store_fname:
mimetype = magic.from_file( mimetype = magic.from_file(
@ -59,7 +60,7 @@ class IrAttachment(models.Model):
mimetype) mimetype)
except ImportError: except ImportError:
(mimetype, encoding) = mimetypes.guess_type( (mimetype, encoding) = mimetypes.guess_type(
'data:;base64,' + this[binary_field], strict=False) 'data:;base64,' + str(this[binary_field]), strict=False)
_logger.debug('Mimetypes guessed type %s from buffer', _logger.debug('Mimetypes guessed type %s from buffer',
mimetype) mimetype)
extension = mimetypes.guess_extension( extension = mimetypes.guess_extension(

View File

@ -1,4 +1,4 @@
Addon icon Module icon
---------- -----------
* courtesy of http://commons.wikimedia.org/wiki/Crystal_Clear * courtesy of http://commons.wikimedia.org/wiki/Crystal_Clear

View File

@ -1,4 +1,4 @@
This addon allows to preview attachments supported by http://viewerjs.org. This module allows to preview attachments supported by http://viewerjs.org.
Currently, that's most Libreoffice files and PDFs. Currently, that's most Libreoffice files and PDFs.

View File

@ -1,4 +1,4 @@
For filetype recognition, you'll get the best results by installing For filetype recognition, you'll get the best results by installing
``python-magic``: ``python-magic``:
sudo apt-get install python-magic sudo apt-get install python3-magic

View File

@ -4,7 +4,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>Preview attachments</title> <title>Attachment Preview</title>
<style type="text/css"> <style type="text/css">
/* /*
@ -367,8 +367,8 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/knowledge/tree/11.0/attachment_preview"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/knowledge-11-0/knowledge-11-0-attachment_preview"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/118/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/knowledge/tree/12.0/attachment_preview"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-attachment_preview"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/118/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This addon allows to preview attachments supported by <a class="reference external" href="http://viewerjs.org">http://viewerjs.org</a>.</p> <p>This module allows to preview attachments supported by <a class="reference external" href="http://viewerjs.org">http://viewerjs.org</a>.</p>
<p>Currently, thats most Libreoffice files and PDFs.</p> <p>Currently, thats most Libreoffice files and PDFs.</p>
<img alt="Screenshot of split form view" src="https://raw.githubusercontent.com/attachment_preview/static/description/screenshot-split.png" style="width: 100%;" /> <img alt="Screenshot of split form view" src="https://raw.githubusercontent.com/attachment_preview/static/description/screenshot-split.png" style="width: 100%;" />
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
@ -381,7 +381,7 @@ ul.auto-toc {
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li> <li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li> <li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="id7">Other credits</a><ul> <li><a class="reference internal" href="#other-credits" id="id7">Other credits</a><ul>
<li><a class="reference internal" href="#addon-icon" id="id8">Addon icon</a></li> <li><a class="reference internal" href="#module-icon" id="id8">Module icon</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference internal" href="#maintainers" id="id9">Maintainers</a></li> <li><a class="reference internal" href="#maintainers" id="id9">Maintainers</a></li>
@ -409,7 +409,7 @@ next to the navigational buttons you can open the preview in a separate window.<
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -430,8 +430,8 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</div> </div>
<div class="section" id="other-credits"> <div class="section" id="other-credits">
<h2><a class="toc-backref" href="#id7">Other credits</a></h2> <h2><a class="toc-backref" href="#id7">Other credits</a></h2>
<div class="section" id="addon-icon"> <div class="section" id="module-icon">
<h3><a class="toc-backref" href="#id8">Addon icon</a></h3> <h3><a class="toc-backref" href="#id8">Module icon</a></h3>
<ul class="simple"> <ul class="simple">
<li>courtesy of <a class="reference external" href="http://commons.wikimedia.org/wiki/Crystal_Clear">http://commons.wikimedia.org/wiki/Crystal_Clear</a></li> <li>courtesy of <a class="reference external" href="http://commons.wikimedia.org/wiki/Crystal_Clear">http://commons.wikimedia.org/wiki/Crystal_Clear</a></li>
</ul> </ul>
@ -444,7 +444,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/11.0/attachment_preview">OCA/knowledge</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/12.0/attachment_preview">OCA/knowledge</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@ -22,6 +22,5 @@
url('/ViewerJS/fonts/Exotica-webfont.svg#exoticamedium') format('svg'); url('/ViewerJS/fonts/Exotica-webfont.svg#exoticamedium') format('svg');
font-weight: normal; font-weight: normal;
font-style: normal; font-style: normal;
} }

View File

@ -257,13 +257,13 @@ odoo.define('attachment_preview', function (require) {
}, },
show: function () { show: function () {
this.$el.removeClass('hidden'); this.$el.removeClass('d-none');
this.trigger('shown'); this.trigger('shown');
}, },
hide: function () { hide: function () {
this.$el.addClass('hidden'); this.$el.addClass('d-none');
this.trigger('hidden'); this.trigger('d-none');
}, },
updatePaginator: function () { updatePaginator: function () {
@ -295,7 +295,7 @@ odoo.define('attachment_preview', function (require) {
init: function () { init: function () {
var res = this._super.apply(this, arguments); var res = this._super.apply(this, arguments);
this.attachmentPreviewWidget = new AttachmentPreviewWidget(this); this.attachmentPreviewWidget = new AttachmentPreviewWidget(this);
this.attachmentPreviewWidget.on('hidden', this, this._attachmentPreviewWidgetHidden); this.attachmentPreviewWidget.on('d-none', this, this._attachmentPreviewWidgetHidden);
return res; return res;
}, },

View File

@ -35,7 +35,7 @@
> .attachment_preview_iframe { > .attachment_preview_iframe {
width: 100%; width: 100%;
height: calc(~"100% - 30px"); height: calc(100% - 30px);
float: left; float: left;
} }
@ -44,7 +44,7 @@
float: left; float: left;
width: 100%; width: 100%;
background-color: #FFF; background-color: #FFF;
border-left: 1px solid @gray-lighter-dark; border-left: 1px solid gray('300');
button { button {
min-width: 25px; min-width: 25px;

View File

@ -18,18 +18,18 @@
</t> </t>
<t t-name="attachment_preview.AttachmentPreviewWidget"> <t t-name="attachment_preview.AttachmentPreviewWidget">
<div class="attachment_preview_widget hidden"> <div class="attachment_preview_widget d-none">
<div class="attachment_preview_buttons"> <div class="attachment_preview_buttons">
<div class="button-group pull-left"> <div class="button-group float-left">
<button class="btn btn-sm btn-default attachment_preview_previous"><i class="fa fa-chevron-left"/></button> <button class="btn btn-secondary attachment_preview_previous"><i class="fa fa-chevron-left"/></button>
<button class="btn btn-sm btn-default disabled attachment_preview_current">1 / 5</button> <button class="btn btn-secondary disabled attachment_preview_current">1 / 5</button>
<button class="btn btn-sm btn-default attachment_preview_next"><i class="fa fa-chevron-right"/></button> <button class="btn btn-secondary attachment_preview_next"><i class="fa fa-chevron-right"/></button>
</div> </div>
<button class="btn btn-sm btn-default pull-left ml8 attachment_preview_popout"><i class="fa fa-external-link"/></button> <button class="btn btn-secondary pull-left ml8 attachment_preview_popout"><i class="fa fa-external-link"/></button>
<button class="btn btn-sm btn-default pull-right attachment_preview_close"><i class="fa fa-times"/></button> <button class="btn btn-secondary pull-right attachment_preview_close"><i class="fa fa-times"/></button>
</div> </div>
<iframe class="attachment_preview_iframe"></iframe> <iframe class="attachment_preview_iframe"/>
</div> </div>
</t> </t>
</templates> </templates>

View File

@ -2,8 +2,8 @@
<odoo> <odoo>
<template id="assets_backend" name="attachment_preview assets" inherit_id="web.assets_backend"> <template id="assets_backend" name="attachment_preview assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside"> <xpath expr="." position="inside">
<script type="text/javascript" src="/attachment_preview/static/src/js/attachment_preview.js"></script> <script type="text/javascript" src="/attachment_preview/static/src/js/attachment_preview.js"/>
<link rel="stylesheet" type="text/less" href="/attachment_preview/static/src/less/attachment_preview.less" /> <link rel="stylesheet" type="text/scss" href="/attachment_preview/static/src/scss/attachment_preview.scss"/>
</xpath> </xpath>
</template> </template>
</odoo> </odoo>

View File

@ -1,4 +1,3 @@
# Copyright 2018 Onestein
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_attachment_preview from . import test_attachment_preview