diff --git a/image_capture_upload_widget/README.rst b/image_capture_upload_widget/README.rst new file mode 100644 index 000000000..33632b49c --- /dev/null +++ b/image_capture_upload_widget/README.rst @@ -0,0 +1,37 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Image Capture Widget +======================= +This module allow to Capture images from the webcam . + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +Developer: Megha K @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: ``__ \ No newline at end of file diff --git a/image_capture_upload_widget/__init__.py b/image_capture_upload_widget/__init__.py new file mode 100644 index 000000000..44c9b1916 --- /dev/null +++ b/image_capture_upload_widget/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Megha K (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 wizard diff --git a/image_capture_upload_widget/__manifest__.py b/image_capture_upload_widget/__manifest__.py new file mode 100644 index 000000000..6e5a5ed45 --- /dev/null +++ b/image_capture_upload_widget/__manifest__.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Megha K (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': 'Image Capture Widget', + 'version': '16.0.1.0.0', + 'category': 'Extra Tools', + 'sequence': '20', + 'summary': 'Image Capture Widget for Image Field. ' + 'This module allows to capture the users image from the webcam.', + 'author': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'description': "This module is used to add Image Capture Widget for Image " + "Field. We can capture the image from the webcam and " + "upload into the binary field", + 'depends': ['base'], + 'images': ['static/description/banner.jpg'], + 'data': [ + 'security/ir.model.access.csv', + 'wizard/image_capture_views.xml' + ], + 'assets': { + 'web.assets_backend': [ + '/image_capture_upload_widget/static/src/scss/image_capture.scss', + '/image_capture_upload_widget/static/src/js/image_capture.js', + '/image_capture_upload_widget/static/src/js/image_upload.js', + '/image_capture_upload_widget/static/src/xml/image_capture_templates.xml', + ], + }, + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/image_capture_upload_widget/doc/RELEASE_NOTES.md b/image_capture_upload_widget/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..b37419010 --- /dev/null +++ b/image_capture_upload_widget/doc/RELEASE_NOTES.md @@ -0,0 +1,7 @@ +## Module + +#### 20.03.2023 +#### Version 16.0.1.0.0 +#### ADD + +- Initial commit for Image Capture Widget diff --git a/image_capture_upload_widget/security/ir.model.access.csv b/image_capture_upload_widget/security/ir.model.access.csv new file mode 100644 index 000000000..6ad71571b --- /dev/null +++ b/image_capture_upload_widget/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_image_capture,access.image.capture,model_image_capture,base.group_user,1,1,1,1 diff --git a/image_capture_upload_widget/static/description/assets/icons/check.png b/image_capture_upload_widget/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/check.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/chevron.png b/image_capture_upload_widget/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/chevron.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/cogs.png b/image_capture_upload_widget/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/cogs.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/consultation.png b/image_capture_upload_widget/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/consultation.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/ecom-black.png b/image_capture_upload_widget/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/ecom-black.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/education-black.png b/image_capture_upload_widget/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/education-black.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/hotel-black.png b/image_capture_upload_widget/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/hotel-black.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/license.png b/image_capture_upload_widget/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/license.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/lifebuoy.png b/image_capture_upload_widget/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/lifebuoy.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/manufacturing-black.png b/image_capture_upload_widget/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/manufacturing-black.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/pos-black.png b/image_capture_upload_widget/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/pos-black.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/puzzle.png b/image_capture_upload_widget/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/puzzle.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/restaurant-black.png b/image_capture_upload_widget/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/restaurant-black.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/service-black.png b/image_capture_upload_widget/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/service-black.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/trading-black.png b/image_capture_upload_widget/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/trading-black.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/training.png b/image_capture_upload_widget/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/training.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/update.png b/image_capture_upload_widget/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/update.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/user.png b/image_capture_upload_widget/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/user.png differ diff --git a/image_capture_upload_widget/static/description/assets/icons/wrench.png b/image_capture_upload_widget/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/icons/wrench.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/categories.png b/image_capture_upload_widget/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/categories.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/check-box.png b/image_capture_upload_widget/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/check-box.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/compass.png b/image_capture_upload_widget/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/compass.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/corporate.png b/image_capture_upload_widget/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/corporate.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/customer-support.png b/image_capture_upload_widget/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/customer-support.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/cybrosys-logo.png b/image_capture_upload_widget/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/cybrosys-logo.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/features.png b/image_capture_upload_widget/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/features.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/logo.png b/image_capture_upload_widget/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/logo.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/pictures.png b/image_capture_upload_widget/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/pictures.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/pie-chart.png b/image_capture_upload_widget/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/pie-chart.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/right-arrow.png b/image_capture_upload_widget/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/right-arrow.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/star.png b/image_capture_upload_widget/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/star.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/support.png b/image_capture_upload_widget/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/support.png differ diff --git a/image_capture_upload_widget/static/description/assets/misc/whatsapp.png b/image_capture_upload_widget/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/misc/whatsapp.png differ diff --git a/image_capture_upload_widget/static/description/assets/modules/1.png b/image_capture_upload_widget/static/description/assets/modules/1.png new file mode 100644 index 000000000..a000df6d7 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/modules/1.png differ diff --git a/image_capture_upload_widget/static/description/assets/modules/2.png b/image_capture_upload_widget/static/description/assets/modules/2.png new file mode 100644 index 000000000..b21837312 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/modules/2.png differ diff --git a/image_capture_upload_widget/static/description/assets/modules/3.png b/image_capture_upload_widget/static/description/assets/modules/3.png new file mode 100644 index 000000000..a9c4ec82c Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/modules/3.png differ diff --git a/image_capture_upload_widget/static/description/assets/modules/4.png b/image_capture_upload_widget/static/description/assets/modules/4.png new file mode 100644 index 000000000..17ba4d75f Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/modules/4.png differ diff --git a/image_capture_upload_widget/static/description/assets/modules/5.png b/image_capture_upload_widget/static/description/assets/modules/5.png new file mode 100644 index 000000000..a3194264c Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/modules/5.png differ diff --git a/image_capture_upload_widget/static/description/assets/modules/6.png b/image_capture_upload_widget/static/description/assets/modules/6.png new file mode 100644 index 000000000..e64a5b55c Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/modules/6.png differ diff --git a/image_capture_upload_widget/static/description/assets/screenshots/hero.gif b/image_capture_upload_widget/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..1a3488cb0 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/screenshots/hero.gif differ diff --git a/image_capture_upload_widget/static/description/assets/screenshots/screenshot-1.png b/image_capture_upload_widget/static/description/assets/screenshots/screenshot-1.png new file mode 100644 index 000000000..d48a68e19 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/screenshots/screenshot-1.png differ diff --git a/image_capture_upload_widget/static/description/assets/screenshots/screenshot-2.png b/image_capture_upload_widget/static/description/assets/screenshots/screenshot-2.png new file mode 100644 index 000000000..f780a1837 Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/screenshots/screenshot-2.png differ diff --git a/image_capture_upload_widget/static/description/assets/screenshots/screenshot-3.png b/image_capture_upload_widget/static/description/assets/screenshots/screenshot-3.png new file mode 100644 index 000000000..eda74b74b Binary files /dev/null and b/image_capture_upload_widget/static/description/assets/screenshots/screenshot-3.png differ diff --git a/image_capture_upload_widget/static/description/banner.jpg b/image_capture_upload_widget/static/description/banner.jpg new file mode 100644 index 000000000..9b0d92749 Binary files /dev/null and b/image_capture_upload_widget/static/description/banner.jpg differ diff --git a/image_capture_upload_widget/static/description/icon.png b/image_capture_upload_widget/static/description/icon.png new file mode 100644 index 000000000..9a7db744c Binary files /dev/null and b/image_capture_upload_widget/static/description/icon.png differ diff --git a/image_capture_upload_widget/static/description/index.html b/image_capture_upload_widget/static/description/index.html new file mode 100644 index 000000000..59b027c60 --- /dev/null +++ b/image_capture_upload_widget/static/description/index.html @@ -0,0 +1,563 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+
+ +
+
+
+ +

+ Image Capture Widget

+

Image Capture Widget + +

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

Explore This + Module

+
+ + + + +
+
+ +
+

Overview +

+
+
+
+ This module is used to Capture Image from our Webcam. It is a widget for + image fields to capture the images directly from the webcam. +
+
+ + + +
+
+ +
+

Features +

+
+
+
+
+ + Enterprise and Community compatible. +
+
+ + Capturing Image from webcam +
+
+
+ + + +
+
+ +
+

Screenshots +

+
+
+
+
+

Configuration +

+

Add the 'capture_image' as the widget of an image field

+
+
+

Click the camera button to open the wizard +

+ +
+ +
+

Click the 'Open Camera' button to open the camera +

+ +
+
+

Click the capture button to take image and then click the save image butto for saving the image. +

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

Related + 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

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

Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+91 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/image_capture_upload_widget/static/src/js/image_capture.js b/image_capture_upload_widget/static/src/js/image_capture.js new file mode 100644 index 000000000..2eb20f75f --- /dev/null +++ b/image_capture_upload_widget/static/src/js/image_capture.js @@ -0,0 +1,164 @@ +/** @odoo-module **/ + +import { isMobileOS } from "@web/core/browser/feature_detection"; +import { _lt } 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"; + + +import { Component, useState, onWillUpdateProps } from "@odoo/owl"; +const { DateTime } = luxon; + +export const fileTypeMagicWordMap = { + "/": "jpg", + R: "gif", + i: "png", + P: "svg+xml", +}; + +const placeholder = "/web/static/img/placeholder.png"; + +export function imageCacheKey(value) { + if (value instanceof DateTime) { + return value.ts; + } + return ""; +} + +export class ImageCapture extends Component { + setup() { + this.notification = useService("notification"); + this.isMobile = isMobileOS(); + this.state = useState({ + isValid: true, + }); + + this.rawCacheKey = this.props.record.data.__last_update; + onWillUpdateProps((nextProps) => { + const { record } = this.props; + const { record: nextRecord } = nextProps; + if (record.resId !== nextRecord.resId || nextRecord.mode === "readonly") { + this.rawCacheKey = nextRecord.data.__last_update; + } + }); + } + + get sizeStyle() { + // For getting image style details + 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.value; + } + + getUrl(previewFieldName) { + // getting the details and url of the image + if (this.state.isValid && this.props.value) { + if (isBinarySize(this.props.value)) { + if (!this.rawCacheKey) { + this.rawCacheKey = this.props.record.data.__last_update; + } + 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.value[0]] || "png"; + return `data:image/${magic};base64,${this.props.value}`; + } + } + return placeholder; + } + onFileRemove() { + // removing the images + this.state.isValid = true; + this.props.update(false); + } + onFileUploaded(info) { + // Upload the images + this.state.isValid = true; + this.rawCacheKey = null; + this.props.update(info.data); + } + onFileCaptureImage() { + // Open a window for open the image and capture it + var field = this.props.name; + var id = this.props.record.data.id; + var model = this.props.record.resModel; + this.env.services['action'].doAction({ + type: "ir.actions.act_window", + res_model: 'image.capture', + views: [[false, "form"]], + target: "new", + context: { + "default_record_id": id, + "default_model_name": model, + "default_field_name": field, + }, + }); + } + onLoadFailed() { + this.state.isValid = false; + this.notification.add(this.env._t("Could not display the selected image"), { + type: "danger", + }); + } +} + +ImageCapture.template = "CaptureImage"; +ImageCapture.components = { + FileUploader, +}; +ImageCapture.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 }, +}; +ImageCapture.defaultProps = { + acceptedFileExtensions: "image/*", +}; + +ImageCapture.displayName = _lt("Image"); +ImageCapture.supportedTypes = ["binary"]; + +ImageCapture.fieldDependencies = { + __last_update: { type: "datetime" }, +}; + +ImageCapture.extractProps = ({ attrs }) => { + return { + enableZoom: attrs.options.zoom, + zoomDelay: attrs.options.zoom_delay, + previewImage: attrs.options.preview_image, + acceptedFileExtensions: attrs.options.accepted_file_extensions, + width: + attrs.options.size && Boolean(attrs.options.size[0]) + ? attrs.options.size[0] + : attrs.width, + height: + attrs.options.size && Boolean(attrs.options.size[1]) + ? attrs.options.size[1] + : attrs.height, + }; +}; + +registry.category("fields").add("capture_image", ImageCapture); diff --git a/image_capture_upload_widget/static/src/js/image_upload.js b/image_capture_upload_widget/static/src/js/image_upload.js new file mode 100644 index 000000000..51054ca9d --- /dev/null +++ b/image_capture_upload_widget/static/src/js/image_upload.js @@ -0,0 +1,51 @@ +/** @odoo-module */ + +import { registry } from '@web/core/registry'; + +import { formView } from '@web/views/form/form_view'; +import { FormController } from '@web/views/form/form_controller'; +import { FormRenderer } from '@web/views/form/form_renderer'; +const { useListener } = require("@web/core/utils/hooks"); +import rpc from 'web.rpc'; +import { patch } from "@web/core/utils/patch"; + +patch(FormRenderer.prototype, 'FormRender',{ + setup() { + this._super(); + }, + async OnClickOpenCamera() { + // opening the camera for capture the image + var player = document.getElementById('player'); + var captureButton = document.getElementById('capture'); + var camera = document.getElementById('camera'); + player.classList.remove('d-none'); + captureButton.classList.remove('d-none'); + camera.classList.add('d-none'); + let stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: false }); + player.srcObject = stream; + }, + async OnClickCaptureImage() { + // Capture the image from webcam and close the webcam + var context = snapshot.getContext('2d'); + var canvas = document.getElementById('snapshot') + var save_image = document.getElementById('save_image') + var image = document.getElementById('image'); + var video = document.getElementById('video') + var camera = document.getElementById('camera'); + save_image.classList.remove('d-none'); + context.drawImage(player, 0, 0, 320, 240); + image.value = context.canvas.toDataURL(); + canvas.classList.remove('d-none'); + this.url = context.canvas.toDataURL() + }, + async OnClickSaveImage(){ + // Saving the image to that field + rpc.query({ + model: 'image.capture', + method: 'action_save_image', + args: [[], this.props.record.data, this.url], + }).then(function(results){ + location.reload(); + }) + } +}); diff --git a/image_capture_upload_widget/static/src/scss/image_capture.scss b/image_capture_upload_widget/static/src/scss/image_capture.scss new file mode 100644 index 000000000..e1bb3bec0 --- /dev/null +++ b/image_capture_upload_widget/static/src/scss/image_capture.scss @@ -0,0 +1,18 @@ +.o_field_image { + background-color: var(--ImageField-background-color, transparent); + + button { + transition: opacity ease 400ms; + width: 26px; + height: 26px; + } + + .o_mobile_controls { + button { + width: 30px; + height: 30px; + padding: 6px !important; + } + } +} + diff --git a/image_capture_upload_widget/static/src/xml/image_capture_templates.xml b/image_capture_upload_widget/static/src/xml/image_capture_templates.xml new file mode 100644 index 000000000..259331dee --- /dev/null +++ b/image_capture_upload_widget/static/src/xml/image_capture_templates.xml @@ -0,0 +1,53 @@ + + + + +
+
+ + + + + + + + + +
+ Binary file +
+
+
diff --git a/image_capture_upload_widget/wizard/__init__.py b/image_capture_upload_widget/wizard/__init__.py new file mode 100644 index 000000000..b5fcb7a0c --- /dev/null +++ b/image_capture_upload_widget/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Megha K (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 image_capture diff --git a/image_capture_upload_widget/wizard/image_capture.py b/image_capture_upload_widget/wizard/image_capture.py new file mode 100644 index 000000000..7bbe411c5 --- /dev/null +++ b/image_capture_upload_widget/wizard/image_capture.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Megha K (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 fields, models + + +class ImageCapture(models.TransientModel): + """A model for capturing images""" + _name = 'image.capture' + _description = 'Image Captures' + + name = fields.Char(string='Name', help='Name of the image to capture') + model_name = fields.Char(string='Model Name', help="For getting the model name details") + record_id = fields.Char(string='Record ID', help="For getting the record ID details") + field_name = fields.Char(string='Field Name', help="Field name for uploading the image") + + def action_save_image(self, data, url): + """ + Saving the images to corresponding models + :param dict data: dictionary representing the details of fields. + :param url: Image details. + """ + image = url.split(',') + self.env[data['model_name']].browse(int(data['record_id'])).sudo().write({ + data['field_name']: image[1] + }) diff --git a/image_capture_upload_widget/wizard/image_capture_views.xml b/image_capture_upload_widget/wizard/image_capture_views.xml new file mode 100644 index 000000000..10ea9886c --- /dev/null +++ b/image_capture_upload_widget/wizard/image_capture_views.xml @@ -0,0 +1,43 @@ + + + + + Image Capture + image.capture + form + + + + image.capture.view.form + image.capture + +
+ + + + + + + + +
+
+
+
\ No newline at end of file