diff --git a/setup/web_widget_many2many_binary_preview/odoo/addons/web_widget_many2many_binary_preview b/setup/web_widget_many2many_binary_preview/odoo/addons/web_widget_many2many_binary_preview new file mode 120000 index 000000000000..03908393d274 --- /dev/null +++ b/setup/web_widget_many2many_binary_preview/odoo/addons/web_widget_many2many_binary_preview @@ -0,0 +1 @@ +../../../../web_widget_many2many_binary_preview \ No newline at end of file diff --git a/setup/web_widget_many2many_binary_preview/setup.py b/setup/web_widget_many2many_binary_preview/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/web_widget_many2many_binary_preview/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_widget_many2many_binary_preview/README.rst b/web_widget_many2many_binary_preview/README.rst new file mode 100644 index 000000000000..03c21919e1e5 --- /dev/null +++ b/web_widget_many2many_binary_preview/README.rst @@ -0,0 +1,100 @@ +================================== +Preview in many2many_binary widget +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a26b753aaf8f11eb7d7bca714d7b1aa7a902e9514971f0b743ab69ffddf91baf + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/14.0/web_widget_many2many_binary_preview + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_widget_many2many_binary_preview + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows developers to enable a preview on fields displayed +with widget ``many2many_binary``. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to set the attribute ``preview`` to +``True`` on a field with widget ``many2many_binary``. + +You can fine-tune the preview by setting attributes ``preview_width`` and/or ``preview_height`` to a size in pixels, and ``preview_crop`` to ``top`` or ``bottom``. +------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Hunki Enterprises BV + +Contributors +------------ + +- Holger Brunn + (https://hunki-enterprises.com) + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px + :target: https://github.com/hbrunn + :alt: hbrunn + +Current `maintainer `__: + +|maintainer-hbrunn| + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_widget_many2many_binary_preview/__init__.py b/web_widget_many2many_binary_preview/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/web_widget_many2many_binary_preview/__manifest__.py b/web_widget_many2many_binary_preview/__manifest__.py new file mode 100644 index 000000000000..4478b5b26275 --- /dev/null +++ b/web_widget_many2many_binary_preview/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2024 Hunki Enterprises BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) + +{ + "name": "Preview in many2many_binary widget", + "summary": "Allows developers to enable previews in binary widgets", + "version": "14.0.1.0.0", + "development_status": "Alpha", + "category": "Technical", + "website": "https://github.com/OCA/web", + "author": "Hunki Enterprises BV, Odoo Community Association (OCA)", + "maintainers": ["hbrunn"], + "license": "AGPL-3", + "depends": [ + "web", + ], + "data": [ + "views/templates.xml", + ], + "qweb": [ + "static/src/web_widget_many2many_binary_preview.xml", + ], +} diff --git a/web_widget_many2many_binary_preview/readme/CONTRIBUTORS.md b/web_widget_many2many_binary_preview/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..b28199e1f410 --- /dev/null +++ b/web_widget_many2many_binary_preview/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Holger Brunn \ (https://hunki-enterprises.com) diff --git a/web_widget_many2many_binary_preview/readme/DESCRIPTION.md b/web_widget_many2many_binary_preview/readme/DESCRIPTION.md new file mode 100644 index 000000000000..59dd5848d854 --- /dev/null +++ b/web_widget_many2many_binary_preview/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module allows developers to enable a preview on fields displayed with widget `many2many_binary`. diff --git a/web_widget_many2many_binary_preview/readme/USAGE.md b/web_widget_many2many_binary_preview/readme/USAGE.md new file mode 100644 index 000000000000..807f0ce88f2a --- /dev/null +++ b/web_widget_many2many_binary_preview/readme/USAGE.md @@ -0,0 +1,4 @@ +To use this module, you need to set the attribute `preview` to ``True`` on a field with widget `many2many_binary`. + +You can fine-tune the preview by setting attributes `preview_width` and/or `preview_height` to a size in pixels, and `preview_crop` to ``top`` or ``bottom``. +- diff --git a/web_widget_many2many_binary_preview/static/description/icon.png b/web_widget_many2many_binary_preview/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/web_widget_many2many_binary_preview/static/description/icon.png differ diff --git a/web_widget_many2many_binary_preview/static/description/index.html b/web_widget_many2many_binary_preview/static/description/index.html new file mode 100644 index 000000000000..da91ae725027 --- /dev/null +++ b/web_widget_many2many_binary_preview/static/description/index.html @@ -0,0 +1,446 @@ + + + + + + +Preview in many2many_binary widget + + + +
+

Preview in many2many_binary widget

+ + +

Alpha License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

This module allows developers to enable a preview on fields displayed +with widget many2many_binary.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Usage

+

To use this module, you need to set the attribute preview to +True on a field with widget many2many_binary.

+ +
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Hunki Enterprises BV
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

hbrunn

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_widget_many2many_binary_preview/static/src/web_widget_many2many_binary_preview.js b/web_widget_many2many_binary_preview/static/src/web_widget_many2many_binary_preview.js new file mode 100644 index 000000000000..facc18afa573 --- /dev/null +++ b/web_widget_many2many_binary_preview/static/src/web_widget_many2many_binary_preview.js @@ -0,0 +1,22 @@ +odoo.define("web_widget_many2many_binary_preview", function (require) { + "use strict"; + var relational_fields = require("web.relational_fields"); + relational_fields.FieldMany2ManyBinaryMultiFiles.include({ + show_preview(file) { + return ( + (this.attrs.preview === "true" || this.attrs.preview === "True") && + (file.mimetype || "").startsWith("image/") + ); + }, + getImageUrl(file) { + return _.str.sprintf( + "/web/image/%s/%sx%s/%s%s", + file.id, + this.attrs.preview_width || 0, + this.attrs.preview_height || 0, + file.name, + this.attrs.preview_crop ? "?crop=" + this.attrs.preview_crop : "" + ); + }, + }); +}); diff --git a/web_widget_many2many_binary_preview/static/src/web_widget_many2many_binary_preview.xml b/web_widget_many2many_binary_preview/static/src/web_widget_many2many_binary_preview.xml new file mode 100644 index 000000000000..42cf2f3c827b --- /dev/null +++ b/web_widget_many2many_binary_preview/static/src/web_widget_many2many_binary_preview.xml @@ -0,0 +1,18 @@ + + + + !widget.show_preview(file) + + + + + + diff --git a/web_widget_many2many_binary_preview/views/templates.xml b/web_widget_many2many_binary_preview/views/templates.xml new file mode 100644 index 000000000000..1ba2a945315b --- /dev/null +++ b/web_widget_many2many_binary_preview/views/templates.xml @@ -0,0 +1,18 @@ + + + +