| 
		 Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 137 KiB  | 
| 
		 Before Width: | Height: | Size: 130 KiB  | 
| 
		 Before Width: | Height: | Size: 190 KiB  | 
| 
		 Before Width: | Height: | Size: 283 KiB  | 
| 
		 After Width: | Height: | Size: 134 KiB  | 
| 
		 After Width: | Height: | Size: 190 KiB  | 
| 
		 After Width: | Height: | Size: 301 KiB  | 
@ -1,51 +0,0 @@ | 
				
			|||||
/** @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(); | 
					 | 
				
			||||
        }) | 
					 | 
				
			||||
    } | 
					 | 
				
			||||
}); | 
					 | 
				
			||||
@ -1,43 +0,0 @@ | 
				
			|||||
<?xml version="1.0" encoding="UTF-8" ?> | 
					 | 
				
			||||
<odoo> | 
					 | 
				
			||||
    <!--Image Capture view and action--> | 
					 | 
				
			||||
    <record id="image_capture_action" model="ir.actions.act_window"> | 
					 | 
				
			||||
        <field name="name">Image Capture</field> | 
					 | 
				
			||||
        <field name="res_model">image.capture</field> | 
					 | 
				
			||||
        <field name="view_mode">form</field> | 
					 | 
				
			||||
    </record> | 
					 | 
				
			||||
 | 
					 | 
				
			||||
    <record id="image_capture_view_form" model="ir.ui.view"> | 
					 | 
				
			||||
        <field name="name">image.capture.view.form</field> | 
					 | 
				
			||||
        <field name="model">image.capture</field> | 
					 | 
				
			||||
        <field name="arch" type="xml"> | 
					 | 
				
			||||
            <form> | 
					 | 
				
			||||
                <sheet> | 
					 | 
				
			||||
                    <group> | 
					 | 
				
			||||
                        <field name="model_name" invisible="True"/> | 
					 | 
				
			||||
                        <field name="record_id" invisible="True"/> | 
					 | 
				
			||||
                        <field name="field_name" invisible="True"/> | 
					 | 
				
			||||
                    </group> | 
					 | 
				
			||||
                    <video id="player" controls="true" class="d-none" | 
					 | 
				
			||||
                           autoplay="true" style="width: 320px;padding: 20px;"/> | 
					 | 
				
			||||
                    <canvas class="d-none" id="snapshot" width="320" | 
					 | 
				
			||||
                            height="240" style="width: 320px;padding: 20px;"/> | 
					 | 
				
			||||
                    <input type="hidden" name="image" id="image"/> | 
					 | 
				
			||||
                </sheet> | 
					 | 
				
			||||
                <footer> | 
					 | 
				
			||||
                    <div id="camera" class="btn btn-primary" | 
					 | 
				
			||||
                         t-on-click="OnClickOpenCamera">Open Camera | 
					 | 
				
			||||
                    </div> | 
					 | 
				
			||||
                    <div id="capture" class="btn btn-primary d-none" | 
					 | 
				
			||||
                         t-on-click="OnClickCaptureImage">Capture | 
					 | 
				
			||||
                    </div> | 
					 | 
				
			||||
                    <div id="save_image" class="btn btn-primary d-none" | 
					 | 
				
			||||
                         t-on-click="OnClickSaveImage">Save Image | 
					 | 
				
			||||
                    </div> | 
					 | 
				
			||||
                    <button string="Cancel" class="btn btn-default" | 
					 | 
				
			||||
                            special="cancel"/> | 
					 | 
				
			||||
                </footer> | 
					 | 
				
			||||
            </form> | 
					 | 
				
			||||
        </field> | 
					 | 
				
			||||
    </record> | 
					 | 
				
			||||
</odoo> | 
					 | 
				
			||||