diff --git a/image_capture_upload_widget/README.rst b/image_capture_upload_widget/README.rst new file mode 100755 index 000000000..ecec93e36 --- /dev/null +++ b/image_capture_upload_widget/README.rst @@ -0,0 +1,51 @@ +.. 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 + +Image Capture Widget +======================= +This module allow to Capture images from the webcam . + +Installation +============ +* Just install the front office management module and this module and set the permission for Reception + +Configuration +============= +* No additional configurations needed + +License +------- +GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (AGPL v3) +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Company +------- +* `Cybrosys Techno Solutions `__ + + +Credits +------- +* Developers: (V15)Ranjith R, 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/image_capture_upload_widget/__init__.py b/image_capture_upload_widget/__init__.py new file mode 100755 index 000000000..8aef26b50 --- /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: Ranjith R (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 100755 index 000000000..3b41b572c --- /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: Ranjith R (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': '15.0.1.0.0', + 'category': 'Extra Tools', + 'summary': 'Image Capture Widget for Image Field. ' + 'This module allows to capture the users image from the webcam.', + '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", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['base'], + 'data': [ + 'security/ir.model.access.csv', + 'wizard/image_capture_views.xml', + ], + 'assets': { + 'web.assets_qweb': [ + 'image_capture_upload_widget/static/src/xml/image_capture_templates.xml', + ], + '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', + ], + }, + 'images': ['static/description/banner.jpg'], + '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 100755 index 000000000..5c3e39b0a --- /dev/null +++ b/image_capture_upload_widget/doc/RELEASE_NOTES.md @@ -0,0 +1,7 @@ +## Module + +#### 28.12.2023 +#### Version 15.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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 index 000000000..baaef2807 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 100755 index 000000000..fb65048fe 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 100755 index 000000000..65f9d71a9 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 100755 index 000000000..e9baebd5d 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 100755 index 000000000..5c8646fae 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 100755 index 000000000..be8dd200b 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..3e9cdec24 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..0a792764a 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..e896a3af6 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..bafbd88d8 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..57d0db717 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..b75c8ed16 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 100755 index 000000000..1944e1e2f --- /dev/null +++ b/image_capture_upload_widget/static/description/index.html @@ -0,0 +1,602 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+ +
+
+
+ +

+ Image Capture Widget

+

+ This custom module provides a that allows users to capture + images directly using their device's camera or upload images + from local storage to any image field within the Odoo + environment. +

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

+ 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, 'oe_avatar' as class 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 button 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 8606827707

+
+
+
+
+
+
+
+ +
+
+
+ \ 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 100755 index 000000000..3b4eb3a8d --- /dev/null +++ b/image_capture_upload_widget/static/src/js/image_capture.js @@ -0,0 +1,74 @@ +odoo.define('image_capture_upload_widget.CaptureImage', function (require) { + "use strict"; + const { getDataURLFromFile } = require('web.utils'); + var basicFields =require('web.basic_fields'); + var rpc = require('web.rpc'); + var core = require('web.core'); + var fieldRegistry = require('web.field_registry'); + const toBase64 = file => new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result); + reader.onerror = error => reject(error); +}); + var QWeb = core.qweb; + var CaptureImage = basicFields.FieldBinaryImage.extend({ + template: 'CaptureImage', + events: { + 'click .o_select_file_button': 'onFileEdit', + 'click .o_upload_image_button': 'onFileUpload', + 'click .o_clear_file_button': 'onFileClear' + }, + onFileEdit: function (ev) { + var self = this; + // Create an input element of type file + var fileInput = document.createElement('input'); + fileInput.type = 'file'; + // Trigger the file selection dialog + fileInput.click(); + // Handle the selected file +fileInput.addEventListener('change', async function (event) { + var file = event.target.files[0]; + if (file) { + // Perform necessary operations with the selected file + var file_image = file_splice.split(',')[1] + //var file_name = ev.target.files[0].name + var record=rpc.query({ + model: self.model, + method: 'write', + args: [[self.res_id], {[self.name] : file_image }], + }).then(function(){ + window.location.reload(); + }); + // You can also upload the file to the server if needed + // Implement the desired functionality for file upload + } + }); +}, +onFileClear: function (ev) { + var self = this; + rpc.query({ + model: self.model, + method: 'write', + args: [[self.res_id], {[self.name] : 0 }], + }).then(function(){ + window.location.reload(); + }); +}, +onFileUpload: function (ev) { + ev.preventDefault(); + var self = this; + // Open form using do_action + var action = { + type: 'ir.actions.act_window', + res_model: 'image.capture', + views: [[false, 'form']], + target: 'new', // Open the form in a new window/tab + context: {'model_name': self.model, 'record_id': self.res_id, 'field_name': self.name} + }; + this.do_action(action); + }, + }); +fieldRegistry.add('capture_image', CaptureImage); + return CaptureImage; +}); 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 100755 index 000000000..9f4842aea --- /dev/null +++ b/image_capture_upload_widget/static/src/js/image_upload.js @@ -0,0 +1,81 @@ +odoo.define('image_capture_upload_widget.image_upload', function (require) { +"use strict"; + const FormController = require('web.FormController'); + const FormView = require('web.FormView'); + const viewRegistry = require('web.view_registry'); + var rpc = require('web.rpc'); + var core = require('web.core'); + var Dialog = require('web.Dialog'); + var _t = core._t; + var data + var url + const CaptureWizardFormRenderer = FormController.extend({ + custom_events: _.extend({}, FormController.prototype.custom_events, { + button_clicked: 'OnClickOpenCamera', + }), + init: function () { + this._super.apply(this, arguments); + const self = this; + data=this.initialState.context + }, + renderButtons: function ($node) { + this._super.apply(this, arguments); + // When clicking on "Add", create a new record in form view + this.$buttons.on('click', '.camera', this.OnClickOpenCamera); + this.$buttons.on('click', '.capture', this.OnClickCaptureImage); + this.$buttons.on('click', '.save_image', this.OnClickSaveImage); + }, +OnClickOpenCamera: async function () { + // opening the camera for capturing 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'); + // Check if the browser supports getUserMedia + if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { + // Request access to the video stream + await navigator.mediaDevices.getUserMedia({ video: true, audio: false }) + .then(function (stream) { + // Success callback, stream is a MediaStream object + player.srcObject = stream; + }) + .catch(function (error) { + }); + } else { + Dialog.alert(self, _t('getUserMedia is not supported in this browser.')) + } +}, +OnClickCaptureImage: function() { + // 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, 300, 200); + image.value = context.canvas.toDataURL(); + canvas.classList.remove('d-none'); + url = context.canvas.toDataURL() + }, + OnClickSaveImage: function(){ + rpc.query({ + model: 'image.capture', + method: 'action_save_image', + args: [[], data, url], + }).then(function(results){ + location.reload(); + }) + } +}); + const CaptureView = FormView.extend({ + config: _.extend({}, FormView.prototype.config, { + Controller: CaptureWizardFormRenderer, + }), + }); + viewRegistry.add('capture_wizard', CaptureView); + return CaptureView; +}); 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 100755 index 000000000..ef855ee73 --- /dev/null +++ b/image_capture_upload_widget/static/src/scss/image_capture.scss @@ -0,0 +1,16 @@ +.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 100755 index 000000000..a5416f87b --- /dev/null +++ b/image_capture_upload_widget/static/src/xml/image_capture_templates.xml @@ -0,0 +1,36 @@ + + + + +
+
+ + +
+ + + + + + +
+ +
+
+
+
+
+
diff --git a/image_capture_upload_widget/wizard/__init__.py b/image_capture_upload_widget/wizard/__init__.py new file mode 100755 index 000000000..e4497fa8d --- /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: Ranjith R (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 100755 index 000000000..7dbf34e68 --- /dev/null +++ b/image_capture_upload_widget/wizard/image_capture.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Ranjith R (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 class 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 100755 index 000000000..4ce4ada49 --- /dev/null +++ b/image_capture_upload_widget/wizard/image_capture_views.xml @@ -0,0 +1,40 @@ + + + + + Image Capture + image.capture + form + + + image.capture.view.form + image.capture + +
+ + + + + + + + +
+
+
+