From 411822d4434f5abf8553a08b12356afc88724d9f Mon Sep 17 00:00:00 2001
From: vancouver29
Date: Mon, 17 Apr 2023 15:57:34 +0200
Subject: [PATCH] [IMP] attachment_preview: fix _onPreviewAttachment and remove
class o_attachment_preview
---
attachment_preview/README.rst | 10 ++++----
.../i18n/attachment_preview.pot | 6 ++---
attachment_preview/i18n/de.po | 4 +--
attachment_preview/i18n/es.po | 17 +++++++++++--
attachment_preview/i18n/it.po | 17 +++++++++++--
attachment_preview/i18n/nl.po | 17 +++++++++++--
attachment_preview/i18n/pt_BR.po | 19 +++++++++++---
attachment_preview/i18n/pt_PT.po | 17 +++++++++++--
attachment_preview/i18n/sl.po | 17 +++++++++++--
attachment_preview/i18n/tr.po | 19 +++++++++++---
attachment_preview/i18n/vi_VN.po | 4 +--
attachment_preview/i18n/zh_CN.po | 17 +++++++++++--
.../static/description/index.html | 6 ++---
.../src/js/components/chatter/chatter.esm.js | 5 ++++
.../attachment_card/attachment_card.esm.js | 25 ++++++-------------
.../static/src/xml/attachment_preview.xml | 4 +--
16 files changed, 150 insertions(+), 54 deletions(-)
diff --git a/attachment_preview/README.rst b/attachment_preview/README.rst
index e7a909bd..f1b2bc89 100644
--- a/attachment_preview/README.rst
+++ b/attachment_preview/README.rst
@@ -14,13 +14,13 @@ Preview attachments
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
- :target: https://github.com/OCA/knowledge/tree/12.0/attachment_preview
+ :target: https://github.com/OCA/knowledge/tree/15.0/attachment_preview
:alt: OCA/knowledge
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-attachment_preview
+ :target: https://translation.odoo-community.org/projects/knowledge-15-0/knowledge-15-0-attachment_preview
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/118/12.0
+ :target: https://runbot.odoo-community.org/runbot/118/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -64,7 +64,7 @@ Bug Tracker
Bugs are tracked on `GitHub 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -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
promote its widespread use.
-This module is part of the `OCA/knowledge `_ project on GitHub.
+This module is part of the `OCA/knowledge `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/attachment_preview/i18n/attachment_preview.pot b/attachment_preview/i18n/attachment_preview.pot
index 47cf8282..8814783d 100644
--- a/attachment_preview/i18n/attachment_preview.pot
+++ b/attachment_preview/i18n/attachment_preview.pot
@@ -6,8 +6,6 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2022-08-23 14:25+0000\n"
-"PO-Revision-Date: 2022-08-23 14:25+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -36,8 +34,8 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
-#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
-#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr ""
diff --git a/attachment_preview/i18n/de.po b/attachment_preview/i18n/de.po
index 5d0256f3..f60dcfa8 100644
--- a/attachment_preview/i18n/de.po
+++ b/attachment_preview/i18n/de.po
@@ -10,6 +10,7 @@ msgstr ""
"PO-Revision-Date: 2022-08-23 14:27+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
@@ -36,8 +37,7 @@ msgstr "Vorschau"
#. module: attachment_preview
#. openerp-web
-#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
-#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Vorschau %s"
diff --git a/attachment_preview/i18n/es.po b/attachment_preview/i18n/es.po
index b8caacd1..39bc0da3 100644
--- a/attachment_preview/i18n/es.po
+++ b/attachment_preview/i18n/es.po
@@ -26,8 +26,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Open in new page"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Preview"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Previsualizar %s"
diff --git a/attachment_preview/i18n/it.po b/attachment_preview/i18n/it.po
index da59b04f..c783d479 100644
--- a/attachment_preview/i18n/it.po
+++ b/attachment_preview/i18n/it.po
@@ -26,8 +26,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Open in new page"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Preview"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Anteprima %s"
diff --git a/attachment_preview/i18n/nl.po b/attachment_preview/i18n/nl.po
index d342e606..658a0479 100644
--- a/attachment_preview/i18n/nl.po
+++ b/attachment_preview/i18n/nl.po
@@ -25,8 +25,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Open in new page"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Preview"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Voorbeeld %s"
diff --git a/attachment_preview/i18n/pt_BR.po b/attachment_preview/i18n/pt_BR.po
index 328bc54b..b45e24ed 100644
--- a/attachment_preview/i18n/pt_BR.po
+++ b/attachment_preview/i18n/pt_BR.po
@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * attachment_preview
+# * attachment_preview
#
msgid ""
msgstr ""
@@ -21,8 +21,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Open in new page"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Preview"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr ""
diff --git a/attachment_preview/i18n/pt_PT.po b/attachment_preview/i18n/pt_PT.po
index aa85cf0f..b17f7ab3 100644
--- a/attachment_preview/i18n/pt_PT.po
+++ b/attachment_preview/i18n/pt_PT.po
@@ -26,8 +26,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Open in new page"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Preview"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Antever %s"
diff --git a/attachment_preview/i18n/sl.po b/attachment_preview/i18n/sl.po
index 83361263..aa93b33d 100644
--- a/attachment_preview/i18n/sl.po
+++ b/attachment_preview/i18n/sl.po
@@ -28,8 +28,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Open in new page"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Preview"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Predogled %s"
diff --git a/attachment_preview/i18n/tr.po b/attachment_preview/i18n/tr.po
index 1abf07fa..673f3e61 100644
--- a/attachment_preview/i18n/tr.po
+++ b/attachment_preview/i18n/tr.po
@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * attachment_preview
+# * attachment_preview
#
msgid ""
msgstr ""
@@ -23,8 +23,21 @@ msgstr "Ek"
#. module: attachment_preview
#. openerp-web
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Open in new page"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Preview"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "%s Önizle"
diff --git a/attachment_preview/i18n/vi_VN.po b/attachment_preview/i18n/vi_VN.po
index 651ad0ba..8def4082 100644
--- a/attachment_preview/i18n/vi_VN.po
+++ b/attachment_preview/i18n/vi_VN.po
@@ -10,6 +10,7 @@ msgstr ""
"PO-Revision-Date: 2022-08-23 14:29+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
@@ -36,8 +37,7 @@ msgstr "Xem trước"
#. module: attachment_preview
#. openerp-web
-#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
-#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Xem trước %s"
diff --git a/attachment_preview/i18n/zh_CN.po b/attachment_preview/i18n/zh_CN.po
index 94d7dc4b..e50c2e89 100644
--- a/attachment_preview/i18n/zh_CN.po
+++ b/attachment_preview/i18n/zh_CN.po
@@ -26,8 +26,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
-#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Open in new page"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
+#, python-format
+msgid "Preview"
+msgstr ""
+
+#. module: attachment_preview
+#. openerp-web
+#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "预览 %s"
diff --git a/attachment_preview/static/description/index.html b/attachment_preview/static/description/index.html
index e8cae521..b64e2bd8 100644
--- a/attachment_preview/static/description/index.html
+++ b/attachment_preview/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This addon allows to preview attachments supported by http://viewerjs.org.
Currently, that’s most Libreoffice files and PDFs.
@@ -409,7 +409,7 @@ next to the navigational buttons you can open the preview in a separate window.<
Bugs are tracked on GitHub 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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -444,7 +444,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-
This module is part of the OCA/knowledge project on GitHub.
+
This module is part of the OCA/knowledge project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/attachment_preview/static/src/js/components/chatter/chatter.esm.js b/attachment_preview/static/src/js/components/chatter/chatter.esm.js
index 5eee6df0..393a6706 100644
--- a/attachment_preview/static/src/js/components/chatter/chatter.esm.js
+++ b/attachment_preview/static/src/js/components/chatter/chatter.esm.js
@@ -205,12 +205,17 @@ odoo.define("attachment_preview.chatter", function (require) {
attachment_title,
split_screen
) {
+ if (!canPreview(attachment_extension)) {
+ return;
+ }
+
var url = getUrl(
attachment_id,
attachment_url,
attachment_extension,
attachment_title
);
+
if (split_screen) {
this.trigger("onAttachmentPreview", {url: url});
} else {
diff --git a/attachment_preview/static/src/js/models/attachment_card/attachment_card.esm.js b/attachment_preview/static/src/js/models/attachment_card/attachment_card.esm.js
index 5a381cd9..92626def 100644
--- a/attachment_preview/static/src/js/models/attachment_card/attachment_card.esm.js
+++ b/attachment_preview/static/src/js/models/attachment_card/attachment_card.esm.js
@@ -242,34 +242,23 @@ odoo.define("attachment_preview.attachment_card", function (require) {
$target = $(event.currentTarget),
split_screen = $target.attr("data-target") !== "new",
attachment_id = this.attachment.id,
- attachment_extension = "pdf",
attachment_title = this.attachment.filename,
attachment_url = this.attachment.defaultSource;
active_attachment_id = attachment_id;
- if (attachment_extension) {
+ rpc.query({
+ model: "ir.attachment",
+ method: "get_attachment_extension",
+ args: [attachment_id],
+ }).then(function (extension) {
self._showPreview(
attachment_id,
attachment_url,
- attachment_extension,
+ extension,
attachment_title,
split_screen
);
- } else {
- rpc.query({
- model: "ir.attachment",
- method: "get_attachment_extension",
- args: [attachment_id],
- }).then(function (extension) {
- self.showPreview(
- attachment_id,
- attachment_url,
- extension,
- null,
- split_screen
- );
- });
- }
+ });
},
}
);
diff --git a/attachment_preview/static/src/xml/attachment_preview.xml b/attachment_preview/static/src/xml/attachment_preview.xml
index 0455eb05..92c2094e 100644
--- a/attachment_preview/static/src/xml/attachment_preview.xml
+++ b/attachment_preview/static/src/xml/attachment_preview.xml
@@ -13,7 +13,7 @@
>