diff --git a/many2many_attachment_preview/README.rst b/many2many_attachment_preview/README.rst new file mode 100755 index 000000000..82bd13d63 --- /dev/null +++ b/many2many_attachment_preview/README.rst @@ -0,0 +1,48 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Many2Many Attachment Preview +============================ +This Module will help to preview the attachments in Many2Many fields. + +Configuration +============= +* No additional configurations needed +Company +------- +* `Cybrosys Techno Solutions `__ + +License +======= +GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Credits +------- +* Developer: (V15) Shonima, Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your +issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ + + diff --git a/many2many_attachment_preview/__init__.py b/many2many_attachment_preview/__init__.py new file mode 100644 index 000000000..b48818fe5 --- /dev/null +++ b/many2many_attachment_preview/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Shonima() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import models diff --git a/many2many_attachment_preview/__manifest__.py b/many2many_attachment_preview/__manifest__.py new file mode 100644 index 000000000..b12dd0837 --- /dev/null +++ b/many2many_attachment_preview/__manifest__.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Shonima() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +{ + 'name': "Many2Many Attachment Preview", + 'version': '15.0.1.0.0', + 'summary': """Preview the attachment in Many2Many field""", + 'description': """"This module helps you to preview the attachments in + Many2Many fields.""", + 'category': 'Uncategorized', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "http://www.cybrosys.com", + 'depends': ['base', 'sale_management'], + 'data': ['views/sale_order_views.xml'], + 'assets': { + 'web.assets_backend': [ + 'many2many_attachment_preview/static/src/js/attachment_preview.js', + ], + 'web.assets_qweb': [ + 'many2many_attachment_preview/static/src/xml/attachment_preview.xml', + ], + }, + 'license': 'AGPL-3', + 'images': ['static/description/banner.jpg'], + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/many2many_attachment_preview/doc/RELEASE_NOTES.md b/many2many_attachment_preview/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..154f87d4a --- /dev/null +++ b/many2many_attachment_preview/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 22.04.2024 +#### Version 15.0.1.0.0 +#### ADD +- Initial Commit for Many2Many Attachment Preview diff --git a/many2many_attachment_preview/models/__init__.py b/many2many_attachment_preview/models/__init__.py new file mode 100644 index 000000000..8b37542d4 --- /dev/null +++ b/many2many_attachment_preview/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Shonima() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import sale_order diff --git a/many2many_attachment_preview/models/sale_order.py b/many2many_attachment_preview/models/sale_order.py new file mode 100644 index 000000000..05b454352 --- /dev/null +++ b/many2many_attachment_preview/models/sale_order.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Shonima() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class SaleOrder(models.Model): + """Inherited sale. order class to add a new field for attachments""" + _inherit = 'sale.order' + + attachment_ids = fields.Many2many( + comodel_name='ir.attachment', + string="Attachments", help="Add Multiple attachment file") diff --git a/many2many_attachment_preview/static/description/assets/icons/check.png b/many2many_attachment_preview/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/check.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/chevron.png b/many2many_attachment_preview/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/chevron.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/cogs.png b/many2many_attachment_preview/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/cogs.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/consultation.png b/many2many_attachment_preview/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/consultation.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/ecom-black.png b/many2many_attachment_preview/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/ecom-black.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/education-black.png b/many2many_attachment_preview/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/education-black.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/hotel-black.png b/many2many_attachment_preview/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/hotel-black.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/license.png b/many2many_attachment_preview/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/license.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/lifebuoy.png b/many2many_attachment_preview/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/lifebuoy.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/logo.png b/many2many_attachment_preview/static/description/assets/icons/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/logo.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/manufacturing-black.png b/many2many_attachment_preview/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/manufacturing-black.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/pos-black.png b/many2many_attachment_preview/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/pos-black.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/puzzle.png b/many2many_attachment_preview/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/puzzle.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/restaurant-black.png b/many2many_attachment_preview/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/restaurant-black.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/service-black.png b/many2many_attachment_preview/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/service-black.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/trading-black.png b/many2many_attachment_preview/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/trading-black.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/training.png b/many2many_attachment_preview/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/training.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/update.png b/many2many_attachment_preview/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/update.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/user.png b/many2many_attachment_preview/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/user.png differ diff --git a/many2many_attachment_preview/static/description/assets/icons/wrench.png b/many2many_attachment_preview/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/icons/wrench.png differ diff --git a/many2many_attachment_preview/static/description/assets/modules/barcode_image.png b/many2many_attachment_preview/static/description/assets/modules/barcode_image.png new file mode 100644 index 000000000..cfb5be33c Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/modules/barcode_image.png differ diff --git a/many2many_attachment_preview/static/description/assets/modules/biometric_image.png b/many2many_attachment_preview/static/description/assets/modules/biometric_image.png new file mode 100644 index 000000000..a0969fcb5 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/modules/biometric_image.png differ diff --git a/many2many_attachment_preview/static/description/assets/modules/export_image.png b/many2many_attachment_preview/static/description/assets/modules/export_image.png new file mode 100644 index 000000000..492980ad0 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/modules/export_image.png differ diff --git a/many2many_attachment_preview/static/description/assets/modules/login_image.png b/many2many_attachment_preview/static/description/assets/modules/login_image.png new file mode 100644 index 000000000..4fbe85ac1 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/modules/login_image.png differ diff --git a/many2many_attachment_preview/static/description/assets/modules/payroll_image.png b/many2many_attachment_preview/static/description/assets/modules/payroll_image.png new file mode 100644 index 000000000..7f2815273 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/modules/payroll_image.png differ diff --git a/many2many_attachment_preview/static/description/assets/modules/sale_image.png b/many2many_attachment_preview/static/description/assets/modules/sale_image.png new file mode 100644 index 000000000..004c61a9e Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/modules/sale_image.png differ diff --git a/many2many_attachment_preview/static/description/assets/screenshots/1.png b/many2many_attachment_preview/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..68f050507 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/screenshots/1.png differ diff --git a/many2many_attachment_preview/static/description/assets/screenshots/2.png b/many2many_attachment_preview/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..a33364863 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/screenshots/2.png differ diff --git a/many2many_attachment_preview/static/description/assets/screenshots/hero.gif b/many2many_attachment_preview/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..6f4cd2ca9 Binary files /dev/null and b/many2many_attachment_preview/static/description/assets/screenshots/hero.gif differ diff --git a/many2many_attachment_preview/static/description/banner.jpg b/many2many_attachment_preview/static/description/banner.jpg new file mode 100644 index 000000000..095e0dcfa Binary files /dev/null and b/many2many_attachment_preview/static/description/banner.jpg differ diff --git a/many2many_attachment_preview/static/description/icon.png b/many2many_attachment_preview/static/description/icon.png new file mode 100644 index 000000000..d683bc6ba Binary files /dev/null and b/many2many_attachment_preview/static/description/icon.png differ diff --git a/many2many_attachment_preview/static/description/index.html b/many2many_attachment_preview/static/description/index.html new file mode 100644 index 000000000..12476ce9e --- /dev/null +++ b/many2many_attachment_preview/static/description/index.html @@ -0,0 +1,597 @@ +
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+ +
+
+
+
+ +
+
+
+

+ Many2Many Attachment Preview

+

+ Preview the Attachments. +

+ +
+
+ + + + +
+
+

+ Overview +

+
+ +
+

+ This module helps you preview of the attachments (like pdf, png, jpg etc) which are uploaded in a Many2Many field.

+ +
+
+ +
+
+

+ Configuration +

+
+ +
+

+ No additional configuration required

+ +
+
+ + +
+
+

+ Features +

+
+ +
+
+ +
+
+

+ Community & Enterprise Support

+

+ Available in Odoo 15.0 Community and Enterprise.

+
+
+
+
+ +
+
+

+ Many2Many Attachment Preview.

+

+ Available pdf, png, jpg (image formats) etc.

+
+
+ +
+
+ +
+
+ +
+ +
+
+

+ Screenshots +

+
+
+

+ Can add multiple attachments

+ +
+ +
+

+ Clicking on attachment,we can preview the document.

+ +
+
+ + + +
+
+

Suggested Products

+
+ + +
+
+ + + +
+
+
+

Our Services

+
+
+ +
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+
+ + + +
+
+
+

Our Industries

+
+
+ +
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+ +
+
+ + + + + +
+
+
+

Need Help?

+
+
+
+ + +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + +
\ No newline at end of file diff --git a/many2many_attachment_preview/static/src/js/attachment_preview.js b/many2many_attachment_preview/static/src/js/attachment_preview.js new file mode 100644 index 000000000..a99012147 --- /dev/null +++ b/many2many_attachment_preview/static/src/js/attachment_preview.js @@ -0,0 +1,223 @@ +odoo.define("many2many_attachment_preview.attachment_preview", function(require) { + "use strict"; + var AbstractField = require("web.AbstractField"); + var field_registry = require("web.field_registry"); + var core = require('web.core'); + var _t = core._t; + var qweb = core.qweb; + var many2many_preview = AbstractField.extend({ + template: "FieldBinaryFileUploader", + template_files: "PdcDocument.files", + supportedFieldTypes: ['many2many'], + fieldsToFetch: { + name: { + type: 'char' + }, + mimetype: { + type: 'char' + }, + }, + events: { + 'click .o_attach': '_onAttach', + 'click .o_attachment_delete': '_onDelete', + 'change .o_input_file': '_onFileChanged', + 'click .o_image_box': '_onFilePDF', + 'click .pdc_close': '_onClosePreview', // Add event for close button + }, + /** + * Initializes the widget. + * + * @constructor + */ + init: function() { + this._super.apply(this, arguments); + + if (this.field.type !== 'many2many' || this.field.relation !== 'ir.attachment') { + var msg = _t("The type of the field '%s' must be a many2many field with a relation to 'ir.attachment' model."); + throw _.str.sprintf(msg, this.field.string); + } + + this.uploadedFiles = {}; + this.uploadingFiles = []; + this.fileupload_id = _.uniqueId('oe_fileupload_temp'); + $(window).on(this.fileupload_id, this._onFileLoaded.bind(this)); + + this.metadata = {}; + this.previewOpen = {}; // Object to track open previews for each attachment + }, + /** + * Cleans up resources when the widget is destroyed. + */ + destroy: function() { + this._super(); + $(window).off(this.fileupload_id); + }, + + _getFileId: function(attachment) { + return attachment.id + }, + _getId: function(attachment) { + return attachment.attributes[1].value + }, + _generatedMetadata: function() { + var self = this; + _.each(this.value.data, function(record) { + self.metadata[record.id] = { + allowUnlink: self.uploadedFiles[record.data.id] || false, + FileId: self._getFileId(record.data) + }; + self.previewOpen[record.id] = false; // Initialize preview flag for each attachment + }); + }, + /** + * Renders the widget. + */ + _render: function() { + this._generatedMetadata(); + this.$('.oe_placeholder_files, .o_attachments') + .replaceWith($(qweb.render(this.template_files, { + widget: this, + }))); + this.$('.oe_fileupload').show(); + this.$('.o_image[data-mimetype^="image"]').each(function() { + var $img = $(this); + if (/gif|jpe|jpg|png/.test($img.data('mimetype')) && $img.data('src')) { + $img.css('background-image', "url('" + $img.data('src') + "')"); + } + }); + }, + /** + * Handles the click event on the attachment button. + */ + _onAttach: function() { + this.$('.o_input_file').click(); + }, + + /** + * Handles the click event on the delete attachment button. + */ + _onDelete: function(ev) { + // Used to unlink the attachment + ev.preventDefault(); + ev.stopPropagation(); + + var fileID = $(ev.currentTarget).data('id'); + var record = _.findWhere(this.value.data, { + res_id: fileID + }); + if (record) { + this._setValue({ + operation: 'FORGET', + ids: [record.id], + }); + var metadata = this.metadata[record.id]; + if (!metadata || metadata.allowUnlink) { + this._rpc({ + model: 'ir.attachment', + method: 'unlink', + args: [record.res_id], + }); + } + } + }, + /** + * Handles the change event on the file input field. + */ + _onFileChanged: function(ev) { + var self = this; + ev.stopPropagation(); + + var files = ev.target.files; + var attachment_ids = this.value.res_ids; + if (files.length === 0) + return; + + _.each(files, function(file) { + var record = _.find(self.value.data, function(attachment) { + return attachment.data.name === file.name; + }); + if (record) { + var metadata = self.metadata[record.id]; + if (!metadata || metadata.allowUnlink) { + attachment_ids = _.without(attachment_ids, record.res_id); + self._rpc({ + model: 'ir.attachment', + method: 'unlink', + args: [record.res_id], + }); + } + } + self.uploadingFiles.push(file); + }); + + this._setValue({ + operation: 'REPLACE_WITH', + ids: attachment_ids, + }); + + this.$('form.o_form_binary_form').submit(); + this.$('.oe_fileupload').hide(); + ev.target.value = ""; + }, + /** + * Handles the file loaded event. + */ + _onFileLoaded: function() { + var self = this; + var files = Array.prototype.slice.call(arguments, 1); + this.uploadingFiles = []; + + var attachment_ids = this.value.res_ids; + _.each(files, function(file) { + if (file.error) { + self.do_warn(_t('Uploading Error'), file.error); + } else { + attachment_ids.push(file.id); + self.uploadedFiles[file.id] = true; + } + }); + + this._setValue({ + operation: 'REPLACE_WITH', + ids: attachment_ids, + }); + }, + /** + * Handles the click event on the PDF file. + */ + _onFilePDF: function(ev) { + var self = this; + var recordId = $(ev.currentTarget).data('id'); + + // Check if preview is already open for this attachment + if (!this.previewOpen[recordId]) { + this.previewOpen[recordId] = true; // Set flag to indicate preview is open + + var fieldId = self._getId(ev.currentTarget); + + // Append the preview HTML to the widget element + self.$el.append(` +
+
close
    +
+ +
+ `); + } + }, + /** + * Handles the click event on the close button of the attachment preview. + */ + _onClosePreview: function(ev) { + var recordId = $(ev.currentTarget).closest('.zPDF_iframe').data('record-id'); + delete this.previewOpen[recordId]; // Remove flag for closed preview + + // Close the attachment preview + $(ev.currentTarget).closest('.zPDF_iframe').remove(); + } + }); + + field_registry.add("many2many_preview", many2many_preview); + return many2many_preview +}); + diff --git a/many2many_attachment_preview/static/src/xml/attachment_preview.xml b/many2many_attachment_preview/static/src/xml/attachment_preview.xml new file mode 100644 index 000000000..9e37ab643 --- /dev/null +++ b/many2many_attachment_preview/static/src/xml/attachment_preview.xml @@ -0,0 +1,53 @@ + diff --git a/many2many_attachment_preview/views/sale_order_views.xml b/many2many_attachment_preview/views/sale_order_views.xml new file mode 100644 index 000000000..16801845d --- /dev/null +++ b/many2many_attachment_preview/views/sale_order_views.xml @@ -0,0 +1,16 @@ + + + + + + sale.order.view.form.inherit.many2many.attachment.preview + + + sale.order + + + + + + +