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..61339d172458 --- /dev/null +++ b/web_widget_many2many_binary_preview/README.rst @@ -0,0 +1,102 @@ +================================== +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/16.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-16-0/web-16-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=16.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 ``show_preview`` to +``True`` on a field with widget ``many2many_binary``. + +Known issues / Roadmap +====================== + +- more options about scaling would be nice + +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..e63855c1b087 --- /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": "16.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", + ], + "assets": { + "web.assets_backend": [ + "web_widget_many2many_binary_preview/static/src/*.js", + "web_widget_many2many_binary_preview/static/src/*.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/ROADMAP.md b/web_widget_many2many_binary_preview/readme/ROADMAP.md new file mode 100644 index 000000000000..4946801395c3 --- /dev/null +++ b/web_widget_many2many_binary_preview/readme/ROADMAP.md @@ -0,0 +1 @@ +- more options about scaling would be nice 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..d9e1f6da9758 --- /dev/null +++ b/web_widget_many2many_binary_preview/readme/USAGE.md @@ -0,0 +1 @@ +To use this module, you need to set the attribute `show_preview` to ``True`` on a field with widget `many2many_binary`. 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..553ad42db8c4 --- /dev/null +++ b/web_widget_many2many_binary_preview/static/description/index.html @@ -0,0 +1,443 @@ + + + + + +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 show_preview to +True on a field with widget many2many_binary.

+
+
+

Known issues / Roadmap

+
    +
  • more options about scaling would be nice
  • +
+
+
+

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.esm.js b/web_widget_many2many_binary_preview/static/src/web_widget_many2many_binary_preview.esm.js new file mode 100644 index 000000000000..9588259fa6f0 --- /dev/null +++ b/web_widget_many2many_binary_preview/static/src/web_widget_many2many_binary_preview.esm.js @@ -0,0 +1,22 @@ +/** @odoo-module **/ + +import {Many2ManyBinaryField} from "@web/views/fields/many2many_binary/many2many_binary_field"; +import {patch} from "@web/core/utils/patch"; + +patch(Many2ManyBinaryField.prototype, "web_widget_many2many_binary_preview", { + show_preview(file) { + return this.props.showPreview && (file.mimetype || "").startsWith("image/"); + }, +}); + +const extractProps = Many2ManyBinaryField.extractProps; +Many2ManyBinaryField.extractProps = (params) => { + return { + ...extractProps(params), + showPreview: Boolean(params.attrs.show_preview), + }; +}; +Many2ManyBinaryField.props = { + ...Many2ManyBinaryField.props, + showPreview: {type: Boolean, optional: true}, +}; 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..f3e0439f611f --- /dev/null +++ b/web_widget_many2many_binary_preview/static/src/web_widget_many2many_binary_preview.xml @@ -0,0 +1,19 @@ + + + + !show_preview(file) + + + + + +