diff --git a/g2p_documents/__manifest__.py b/g2p_documents/__manifest__.py index 6e99538c..4a53c6ab 100644 --- a/g2p_documents/__manifest__.py +++ b/g2p_documents/__manifest__.py @@ -21,7 +21,11 @@ "data/storage_backend.xml", ], "external_dependencies": {"python": ["boto3<=1.15.18", "python_slugify"]}, - "assets": {}, + "assets": { + "web.assets_backend": [ + "g2p_documents/static/src/js/preview_document.js", + ], + }, "demo": [], "images": [], "application": True, diff --git a/g2p_registry_documents/static/src/js/preview_document.js b/g2p_documents/static/src/js/preview_document.js similarity index 71% rename from g2p_registry_documents/static/src/js/preview_document.js rename to g2p_documents/static/src/js/preview_document.js index d58aaa01..18b99d06 100644 --- a/g2p_registry_documents/static/src/js/preview_document.js +++ b/g2p_documents/static/src/js/preview_document.js @@ -20,7 +20,6 @@ class Widgetpreview extends Component { const slugElement = currentRow.querySelector('.o_data_cell[name="slug"]'); if (slugElement) { const slugValue = slugElement.textContent.trim(); - console.log("Slug Value:", slugValue); let recordID = 0; if (slugValue.includes("-")) { @@ -45,22 +44,25 @@ class Widgetpreview extends Component { kwargs: {}, }); const mimetype = result.mimetype; - - const file = { - id: recordID, - displayName: result.name, - downloadUrl: result.url, - isViewable: mimetype.includes("image") || mimetype.includes("pdf"), - defaultSource: result.url, - isImage: mimetype.includes("image"), - isPdf: mimetype.includes("pdf"), - }; - if (file.isViewable) { - this.fileViewer.open(file); + if (typeof mimetype === "string" && mimetype) { + const file = { + id: recordID, + displayName: result.name, + downloadUrl: result.url, + isViewable: mimetype.includes("image") || mimetype.includes("pdf"), + defaultSource: result.url, + isImage: mimetype.includes("image"), + isPdf: mimetype.includes("pdf"), + }; + if (file.isViewable) { + this.fileViewer.open(file); + } else { + window.open(result.url, "_blank"); + } } else { window.open(result.url, "_blank"); } } } -registry.category("view_widgets").add("action_preview_registry", {component: Widgetpreview}); +registry.category("view_widgets").add("action_preview", {component: Widgetpreview}); diff --git a/g2p_registry_documents/__manifest__.py b/g2p_registry_documents/__manifest__.py index 67fe93bc..e7ccb57a 100644 --- a/g2p_registry_documents/__manifest__.py +++ b/g2p_registry_documents/__manifest__.py @@ -16,11 +16,7 @@ "data": [ "views/registrant_document_views.xml", ], - "assets": { - "web.assets_backend": [ - "g2p_registry_documents/static/src/js/preview_document.js", - ], - }, + "assets": {}, "demo": [], "images": [], "application": True, diff --git a/g2p_registry_documents/views/registrant_document_views.xml b/g2p_registry_documents/views/registrant_document_views.xml index 20b677d1..5d430088 100644 --- a/g2p_registry_documents/views/registrant_document_views.xml +++ b/g2p_registry_documents/views/registrant_document_views.xml @@ -1,6 +1,6 @@ - + view_registrant_documents_form_individual res.partner @@ -13,7 +13,8 @@ - + + @@ -34,7 +35,8 @@ - + +