diff --git a/drag_and_drop_image_widget/README.rst b/drag_and_drop_image_widget/README.rst new file mode 100644 index 000000000..d52fb3ffe --- /dev/null +++ b/drag_and_drop_image_widget/README.rst @@ -0,0 +1,48 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Drag and Drop Widget +======================= +This is a widget for Drag and drop files into the attachment field. + +Configuration +=============== +Add the 'drag_and_drop' as the widget of an image field. + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (AGPL v3) +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Credits +------- +Developer: Ammu Raj@cybrosys, 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/drag_and_drop_image_widget/__init__.py b/drag_and_drop_image_widget/__init__.py new file mode 100644 index 000000000..cb4455885 --- /dev/null +++ b/drag_and_drop_image_widget/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Ammu Raj (odoo@cybrosys.com) +# +# 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/drag_and_drop_image_widget/__manifest__.py b/drag_and_drop_image_widget/__manifest__.py new file mode 100644 index 000000000..d94a718be --- /dev/null +++ b/drag_and_drop_image_widget/__manifest__.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Ammu Raj (odoo@cybrosys.com) +# +# 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': 'Drag and Drop Widget', + 'version': '17.0.1.0.0', + 'category': 'Extra Tools', + 'summary': 'This is a widget for Drag and drop images into the ' + 'image field', + 'description': "This module is used to drag and drop files into the " + "image field", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['base', 'web'], + 'assets': { + 'web.assets_backend': [ + 'drag_and_drop_image_widget/static/src/scss/drag_and_drop.scss', + 'drag_and_drop_image_widget/static/src/js/drag_and_drop.js', + 'drag_and_drop_image_widget/static/src/xml/drag_and_drop_templates.xml' + ] + }, + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/drag_and_drop_image_widget/doc/RELEASE_NOTES.md b/drag_and_drop_image_widget/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..5dc68ab1e --- /dev/null +++ b/drag_and_drop_image_widget/doc/RELEASE_NOTES.md @@ -0,0 +1,7 @@ +## Module + +#### 31.08.2024 +#### Version 17.0.1.0.0 +#### ADD + +- Initial commit for Drag and Drop Widget diff --git a/drag_and_drop_image_widget/models/__init__.py b/drag_and_drop_image_widget/models/__init__.py new file mode 100644 index 000000000..08278fee6 --- /dev/null +++ b/drag_and_drop_image_widget/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Ammu Raj (odoo@cybrosys.com) +# +# 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 ir_attachment diff --git a/drag_and_drop_image_widget/models/ir_attachment.py b/drag_and_drop_image_widget/models/ir_attachment.py new file mode 100644 index 000000000..b83ca74bb --- /dev/null +++ b/drag_and_drop_image_widget/models/ir_attachment.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Ammu Raj (odoo@cybrosys.com) +# +# 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 models + + +class IrAttachment(models.Model): + """Inheriting the ir attachment and saving the image into the fields""" + _inherit = 'ir.attachment' + + def action_save_drag_and_drop_image(self, data, url): + """Save the image into the fields""" + image = url.split(',') + self.env[data['resModel']].sudo().browse( + int(data['id'])).sudo().write({ + data['name']: image[1] + }) + return True diff --git a/drag_and_drop_image_widget/static/description/assets/icons/capture (1).png b/drag_and_drop_image_widget/static/description/assets/icons/capture (1).png new file mode 100644 index 000000000..8824deafc Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/capture (1).png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/check.png b/drag_and_drop_image_widget/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/check.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/chevron.png b/drag_and_drop_image_widget/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/chevron.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/cogs.png b/drag_and_drop_image_widget/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/cogs.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/consultation.png b/drag_and_drop_image_widget/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/consultation.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/ecom-black.png b/drag_and_drop_image_widget/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/ecom-black.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/education-black.png b/drag_and_drop_image_widget/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/education-black.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/hotel-black.png b/drag_and_drop_image_widget/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/hotel-black.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/img.png b/drag_and_drop_image_widget/static/description/assets/icons/img.png new file mode 100644 index 000000000..70197f477 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/img.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/license.png b/drag_and_drop_image_widget/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/license.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/lifebuoy.png b/drag_and_drop_image_widget/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/lifebuoy.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/manufacturing-black.png b/drag_and_drop_image_widget/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/manufacturing-black.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/photo-capture.png b/drag_and_drop_image_widget/static/description/assets/icons/photo-capture.png new file mode 100644 index 000000000..06c111758 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/photo-capture.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/pos-black.png b/drag_and_drop_image_widget/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/pos-black.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/puzzle.png b/drag_and_drop_image_widget/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/puzzle.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/restaurant-black.png b/drag_and_drop_image_widget/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/restaurant-black.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/service-black.png b/drag_and_drop_image_widget/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/service-black.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/trading-black.png b/drag_and_drop_image_widget/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/trading-black.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/training.png b/drag_and_drop_image_widget/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/training.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/update.png b/drag_and_drop_image_widget/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/update.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/user.png b/drag_and_drop_image_widget/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/user.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/icons/wrench.png b/drag_and_drop_image_widget/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/icons/wrench.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/misc/Cybrosys R.png b/drag_and_drop_image_widget/static/description/assets/misc/Cybrosys R.png new file mode 100644 index 000000000..da4058087 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/misc/Cybrosys R.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/misc/email.svg b/drag_and_drop_image_widget/static/description/assets/misc/email.svg new file mode 100644 index 000000000..15291cdc3 --- /dev/null +++ b/drag_and_drop_image_widget/static/description/assets/misc/email.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/drag_and_drop_image_widget/static/description/assets/misc/phone.svg b/drag_and_drop_image_widget/static/description/assets/misc/phone.svg new file mode 100644 index 000000000..b7bd7f251 --- /dev/null +++ b/drag_and_drop_image_widget/static/description/assets/misc/phone.svg @@ -0,0 +1,3 @@ + + + diff --git a/drag_and_drop_image_widget/static/description/assets/misc/star (1) 2.svg b/drag_and_drop_image_widget/static/description/assets/misc/star (1) 2.svg new file mode 100644 index 000000000..5ae9f507a --- /dev/null +++ b/drag_and_drop_image_widget/static/description/assets/misc/star (1) 2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/drag_and_drop_image_widget/static/description/assets/misc/support (1) 1.svg b/drag_and_drop_image_widget/static/description/assets/misc/support (1) 1.svg new file mode 100644 index 000000000..7d37a8f30 --- /dev/null +++ b/drag_and_drop_image_widget/static/description/assets/misc/support (1) 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/drag_and_drop_image_widget/static/description/assets/misc/support-email.svg b/drag_and_drop_image_widget/static/description/assets/misc/support-email.svg new file mode 100644 index 000000000..eb70370d6 --- /dev/null +++ b/drag_and_drop_image_widget/static/description/assets/misc/support-email.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/drag_and_drop_image_widget/static/description/assets/misc/tick-mark.svg b/drag_and_drop_image_widget/static/description/assets/misc/tick-mark.svg new file mode 100644 index 000000000..2dbb40187 --- /dev/null +++ b/drag_and_drop_image_widget/static/description/assets/misc/tick-mark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/drag_and_drop_image_widget/static/description/assets/misc/whatsapp 1.svg b/drag_and_drop_image_widget/static/description/assets/misc/whatsapp 1.svg new file mode 100644 index 000000000..0bfaf8fc6 --- /dev/null +++ b/drag_and_drop_image_widget/static/description/assets/misc/whatsapp 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/drag_and_drop_image_widget/static/description/assets/misc/whatsapp.svg b/drag_and_drop_image_widget/static/description/assets/misc/whatsapp.svg new file mode 100644 index 000000000..b618aea1d --- /dev/null +++ b/drag_and_drop_image_widget/static/description/assets/misc/whatsapp.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/drag_and_drop_image_widget/static/description/assets/modules/1.png b/drag_and_drop_image_widget/static/description/assets/modules/1.png new file mode 100644 index 000000000..b2e9fb2e6 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/modules/1.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/modules/2.png b/drag_and_drop_image_widget/static/description/assets/modules/2.png new file mode 100644 index 000000000..195067b09 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/modules/2.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/modules/3.png b/drag_and_drop_image_widget/static/description/assets/modules/3.png new file mode 100644 index 000000000..1ced41829 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/modules/3.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/modules/4.png b/drag_and_drop_image_widget/static/description/assets/modules/4.png new file mode 100644 index 000000000..261da0295 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/modules/4.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/modules/5.png b/drag_and_drop_image_widget/static/description/assets/modules/5.png new file mode 100644 index 000000000..74a7976c6 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/modules/5.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/modules/6.png b/drag_and_drop_image_widget/static/description/assets/modules/6.png new file mode 100644 index 000000000..94d27aa9e Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/modules/6.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/screenshots/1.png b/drag_and_drop_image_widget/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..a8204db7c Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/screenshots/1.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/screenshots/2.png b/drag_and_drop_image_widget/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..b13de1c96 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/screenshots/2.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/screenshots/3.png b/drag_and_drop_image_widget/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..30862a3a6 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/screenshots/3.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/screenshots/4.png b/drag_and_drop_image_widget/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..d47b6fd13 Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/screenshots/4.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/screenshots/5.png b/drag_and_drop_image_widget/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..69ff675ad Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/screenshots/5.png differ diff --git a/drag_and_drop_image_widget/static/description/assets/screenshots/hero.gif b/drag_and_drop_image_widget/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..99165ec8f Binary files /dev/null and b/drag_and_drop_image_widget/static/description/assets/screenshots/hero.gif differ diff --git a/drag_and_drop_image_widget/static/description/banner.jpg b/drag_and_drop_image_widget/static/description/banner.jpg new file mode 100644 index 000000000..52432518c Binary files /dev/null and b/drag_and_drop_image_widget/static/description/banner.jpg differ diff --git a/drag_and_drop_image_widget/static/description/icon.png b/drag_and_drop_image_widget/static/description/icon.png new file mode 100644 index 000000000..6afa9afbd Binary files /dev/null and b/drag_and_drop_image_widget/static/description/icon.png differ diff --git a/drag_and_drop_image_widget/static/description/index.html b/drag_and_drop_image_widget/static/description/index.html new file mode 100644 index 000000000..bebd7973d --- /dev/null +++ b/drag_and_drop_image_widget/static/description/index.html @@ -0,0 +1,587 @@ + + + + + + + Odoo App 3 Index + + + + + + + + +
+
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+
+
+
+

+ Drag and Drop Widget

+

+ Drag and Drop Widget for Image Fields. +

+
+ +
+
+
+
+
+

Key Highlights +

+
+
+
+
+
+ +
+
+

Enterprise, Community and Odoo SH compatible.

+
+
+
+
+
+
+ +
+
+

Simply Drag and drop Images.

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

+ Add the 'drag_and_drop' as the widget of an image field of form view.

+
+
+
+
+
+
+ +
+
+

+ Click the Up Arrow button to start the drag and drop operation.

+
+
+
+
+
+
+ +
+
+

+ Drag and drop images to this area.

+
+
+
+
+
+
+ +
+
+

+ Drag the image and click the Upload image button.

+
+
+
+
+
+
+ +
+
+

+ Image uploaded.

+
+
+
+
+
+
+
    +
  • + Customer can attach files in the "my account" screen and "payment" screen. +
  • +
  • + Customer can upload both image and pdf files. +
  • +
  • + Customer can upload multiple files. +
  • +
  • + It is available for all manual transactions. +
  • +
  • + Admin can see the uploaded file in the sale order section. +
  • +
+
+
+
+
+
+
Version + 17.0.1.0.0|Released on:20th January 2024 +
+

+ + Initial Commit for Payment Proof Attachment.

+
+
+
+
+
+
+
+

Related Products

+
+
+ +
+
+

Our Services

+ +
+
+
+
+
+
+
+
+ service-icon +
+
+

Odoo Customization

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Support

+
+
+
+
+
+
+ service-icon +
+
+

Hire Odoo Developer

+
+
+
+
+ +
+
+ service-icon +
+
+

Odoo Integration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Migration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Consultancy

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Implementation

+
+
+
+
+
+
+ service-icon +
+
+

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

+
+
+
+
+
+
+

Support

+
+
+
+
+
+
+
+ +
+ Need + Help? +

Got questions or need help? Get in touch.

+
odoo@cybrosys.com +
+
+
+
+
+
+
+
+ +
+ WhatsApp +

Say hi to us on WhatsApp!

+
+91 + 99456767686
+
+
+
+
+
+
+
+
+ + + + + + diff --git a/drag_and_drop_image_widget/static/src/js/drag_and_drop.js b/drag_and_drop_image_widget/static/src/js/drag_and_drop.js new file mode 100644 index 000000000..d37103af1 --- /dev/null +++ b/drag_and_drop_image_widget/static/src/js/drag_and_drop.js @@ -0,0 +1,302 @@ +/** @odoo-module **/ + +import { isMobileOS } from "@web/core/browser/feature_detection"; +import { _t } from "@web/core/l10n/translation"; +import { registry } from "@web/core/registry"; +import { useService } from "@web/core/utils/hooks"; +import { url } from "@web/core/utils/urls"; +import { isBinarySize } from "@web/core/utils/binary"; +import { FileUploader } from "@web/views/fields/file_handler"; +import { standardFieldProps } from "@web/views/fields/standard_field_props"; +const { useRef } = owl; +import { onWillUpdateProps } from "@odoo/owl"; + + +import { Component, useState } from "@odoo/owl"; +const { DateTime } = luxon; + +export const fileTypeMagicWordMap = { + "/": "jpg", + R: "gif", + i: "png", + P: "svg+xml", + U: "webp", +}; +const placeholder = "/web/static/img/placeholder.png"; + +export function imageCacheKey(value) { + if (value instanceof DateTime) { + return value.ts; + } + return ""; +} + +export class DragAndDropBinaryField extends Component { + static components = { + FileUploader, + }; + static props = { + ...standardFieldProps, + enableZoom: { + type: Boolean, + optional: true + }, + zoomDelay: { + type: Number, + optional: true + }, + previewImage: { + type: String, + optional: true + }, + acceptedFileExtensions: { + type: String, + optional: true + }, + width: { + type: Number, + optional: true + }, + height: { + type: Number, + optional: true + }, + reload: { + type: Boolean, + optional: true + }, + }; + static defaultProps = { + acceptedFileExtensions: "image/*", + reload: true, + }; + + setup() { + this.orm = useService('orm'); + this.notification = useService("notification"); + this.orm = useService("orm"); + this.isMobile = isMobileOS(); + this.state = useState({ + isValid: true, + }); + this.inputFile = useRef('inputFile') + this.image_picker = useRef('image_picker') + this.rawCacheKey = this.props.record.data.write_date; + onWillUpdateProps((nextProps) => { + const { + record + } = this.props; + const { + record: nextRecord + } = nextProps; + if (record.resId !== nextRecord.resId || nextRecord.mode === "readonly") { + this.rawCacheKey = nextRecord.data.write_date; + } + }); + } + get sizeStyle() { + let style = ""; + if (this.props.width) { + style += `max-width: ${this.props.width}px;`; + } + if (this.props.height) { + style += `max-height: ${this.props.height}px;`; + } + return style; + } + get hasTooltip() { + return ( + this.props.enableZoom && this.props.readonly && this.props.record.data[this.props.name] + ); + } + + getUrl(previewFieldName) { + if (!this.rawCacheKey) { + this.rawCacheKey = this.props.record.data.write_date; + } + if (this.state.isValid && this.props.record.data[this.props.name]) { + if (isBinarySize(this.props.record.data[this.props.name])) { + return url("/web/image", { + model: this.props.record.resModel, + id: this.props.record.resId, + field: previewFieldName, + unique: imageCacheKey(this.rawCacheKey), + }); + } else { + // Use magic-word technique for detecting image type + const magic = + fileTypeMagicWordMap[this.props.record.data[this.props.name][0]] || "png"; + this.lastURL = `data:image/${magic};base64,${ + this.props.record.data[this.props.name] + }`; + } + } + return placeholder; + } + onFileRemove() { + this.state.isValid = true; + this.props.record.update({ + [this.props.name]: false + }); + } + async onFileUploaded(info) { + this.rawCacheKey = null; + this.state.isValid = true; + if (info.type === "image/webp") { + // Generate alternate sizes and format for reports. + const image = document.createElement("img"); + image.src = `data:image/webp;base64,${info.data}`; + await new Promise((resolve) => image.addEventListener("load", resolve)); + const originalSize = Math.max(image.width, image.height); + const smallerSizes = [1024, 512, 256, 128].filter((size) => size < originalSize); + let referenceId = undefined; + for (const size of [originalSize, ...smallerSizes]) { + const ratio = size / originalSize; + const canvas = document.createElement("canvas"); + canvas.width = image.width * ratio; + canvas.height = image.height * ratio; + const ctx = canvas.getContext("2d"); + ctx.fillStyle = "rgb(255, 255, 255)"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + ctx.drawImage( + image, + 0, + 0, + image.width, + image.height, + 0, + 0, + canvas.width, + canvas.height + ); + const [resizedId] = await this.orm.call("ir.attachment", "create_unique", [ + [{ + name: info.name, + description: size === originalSize ? "" : `resize: ${size}`, + datas: size === originalSize ? + info.data : + canvas.toDataURL("image/webp", 0.75).split(",")[1], + res_id: referenceId, + res_model: "ir.attachment", + mimetype: "image/webp", + }, ], + ]); + referenceId = referenceId || resizedId; // Keep track of original. + await this.orm.call("ir.attachment", "create_unique", [ + [{ + name: info.name.replace(/\.webp$/, ".jpg"), + description: "format: jpeg", + datas: canvas.toDataURL("image/jpeg", 0.75).split(",")[1], + res_id: resizedId, + res_model: "ir.attachment", + mimetype: "image/jpeg", + }, ], + ]); + } + } + this.props.record.update({ + [this.props.name]: info.data + }); + } + onLoadFailed() { + this.state.isValid = false; + this.notification.add(_t("Could not display the selected image"), { + type: "danger", + }); + } + /* Upload Image to the field */ + async onImageUpload() { + let file = this.inputFile.el.defaultValue + if (file == "") { + image_picker.classList.add('d-none'); + } else { + this.orm.call('ir.attachment', 'action_save_drag_and_drop_image', [ + [], + { + 'resModel': this.props.record.resModel, + 'id': this.props.record._config.resId, + 'name': this.props.name + }, + file + ]) + .then((result) => { + location.reload(); + }) + } + } + /* method for dragging */ + onFileDragImage() { + var image_picker = this.image_picker.el; + image_picker.classList.remove('d-none'); + } +} +DragAndDropBinaryField.template = 'FieldDragAndDropBinary'; +export const dragAndDropBinaryField = { + component: DragAndDropBinaryField, + displayName: _t("Image"), + supportedOptions: [{ + label: _t("Reload"), + name: "reload", + type: "boolean", + default: true, + }, + { + label: _t("Enable zoom"), + name: "zoom", + type: "boolean", + }, + { + label: _t("Zoom delay"), + name: "zoom_delay", + type: "number", + help: _t("Delay the apparition of the zoomed image with a value in milliseconds"), + }, + { + label: _t("Accepted file extensions"), + name: "accepted_file_extensions", + type: "string", + }, + { + label: _t("Size"), + name: "size", + type: "selection", + choices: [{ + label: _t("Small"), + value: "[0,90]" + }, + { + label: _t("Medium"), + value: "[0,180]" + }, + { + label: _t("Large"), + value: "[0,270]" + }, + ], + }, + { + label: _t("Preview image"), + name: "preview_image", + type: "field", + availableTypes: ["binary"], + }, + ], + supportedTypes: ["binary"], + fieldDependencies: [{ + name: "write_date", + type: "datetime" + }], + isEmpty: () => false, + extractProps: ({ + attrs, + options + }) => ({ + enableZoom: options.zoom, + zoomDelay: options.zoom_delay, + previewImage: options.preview_image, + acceptedFileExtensions: options.accepted_file_extensions, + width: options.size && Boolean(options.size[0]) ? options.size[0] : attrs.width, + height: options.size && Boolean(options.size[1]) ? options.size[1] : attrs.height, + }), +}; +registry.category("fields").add("drag_and_drop", dragAndDropBinaryField); diff --git a/drag_and_drop_image_widget/static/src/scss/drag_and_drop.scss b/drag_and_drop_image_widget/static/src/scss/drag_and_drop.scss new file mode 100644 index 000000000..25979c939 --- /dev/null +++ b/drag_and_drop_image_widget/static/src/scss/drag_and_drop.scss @@ -0,0 +1,192 @@ +@import url(https://fonts.googleapis.com/css?family=Open+Sans); + +@basecolor: #f80; +@dropperbg: hsl(0, 0%, 90%); + +*, +*:before, +*:after { + box-sizing: border-box; +} +body { + background: #eee; + font-family: "Open Sans", Helvetica, sans-serif; +} +.setting { + background: #fff; + margin: 0 auto 3px; + padding: 12px; + width: 300px; + h2 { + color: #999; + font-size: 14px; + font-weight: 400; + margin: 0 0 6px; + line-height: 24px; + } + a[data-action] { + cursor: pointer; + color: #555; + font-size: 14px; + line-height: 24px; + transition: color 0.2s; + i { + width: 1.25em; + text-align: center; + } + &:hover { + color: #f80; + } + &.disabled { + opacity: 0.35; + cursor: default; + &:hover { + color: #555; + } + } + } +} +.image_picker .settings_wrap { + overflow: hidden; + position: relative; + .drop_target, + .settings_actions { + float: left; + } + .drop_target { + margin-right: 18px; + } + .settings_actions { + margin-top: 12px; + } +} +.settings_actions.vertical { + a { + display: block; + } +} +.drop_target { + position: relative; + cursor: pointer; + background: hsl(0, 0%, 90%); + border-top: 1px solid darken(hsl(0, 0%, 90%), 10%); + border-radius: 4px; + width: 72px; + height: 72px; + padding: 4px 6px 6px; + transition: all 0.2s; + input[type="file"] { + visibility: hidden; + } + &:before { + content: "\f0ee"; + font-family: FontAwesome; + position: absolute; + display: block; + width: 60px; + line-height: 60px; + text-align: center; + font-size: 32px; + color: fadeout(#000, 70%); + transition: color 0.2s; + } + &:hover, + &.dropping { + background: #aca8a3; + border-top-color: darken(#0d0d0d, 10%); + } + &:hover:before, + &.dropping:before { + color: fadeout(#000, 40%); + } + .image_preview { + width: 100%; + height: 100%; + background: no-repeat center; + background-size: contain; + position: relative; + z-index: 2; + } +} +.image_details { + width: 192px; + padding: 4px; + background: hsl(0, 0%, 90%); + border-radius: 4px; + position: absolute; + top: 0; + left: 84px; + z-index: 5; + opacity: 0; + pointer-events: none; + transition: opacity 0.4s; + .dropped ~ & { + opacity: 1; + pointer-events: all; + } + &:before { + content: ""; + display: block; + width: 0; + height: 0; + border: 6px solid transparent; + border-right-color: hsl(0, 0%, 90%); + position: absolute; + left: -12px; + top: 10px; + } + .input_line { + display: block; + overflow: hidden; + margin-bottom: 4px; + &:last-of-type { + margin-bottom: 0; + } + span, + input { + float: left; + line-height: 24px; + } + span { + font-size: 12px; + color: #666; + width: 20%; + } + input[type="text"] { + width: 100%; + color: #444444; + appearance: none; + border: 1px solid hsl(0, 0%, 90%); + border-radius: 3px; + background: #fff; + height: 24px; + line-height: 18px; + padding: 3px 5px; + font-size: 14px; + transition: border 0.2s; + &:hover, + &:focus { + outline: 0; + border: 1px solid #f80; + } + &::-webkit-input-placeholder { + font-size: 14px; + color: #999; + } + } + } + a.confirm { + position: absolute; + right: -12px; + top: 50%; + margin-top: -12px; + display: block; + width: 21px; + height: 21px; + border-radius: 100%; + background: #eee; + line-height: 23px; + text-align: center; + font-size: 16px; + } +} diff --git a/drag_and_drop_image_widget/static/src/xml/drag_and_drop_templates.xml b/drag_and_drop_image_widget/static/src/xml/drag_and_drop_templates.xml new file mode 100644 index 000000000..a95475c7c --- /dev/null +++ b/drag_and_drop_image_widget/static/src/xml/drag_and_drop_templates.xml @@ -0,0 +1,121 @@ + + + + +
+
+ + + + + + + + + +
+ Binary file +
+
+
+
+ + + +
+ +
+
+