3
0
Fork 0

[11.0][MIG] web_widget_image_webcam: code migration

11.0
Siddharth Bhalgami 2019-07-03 11:11:04 +08:00
parent 0b16e67a74
commit a8b6512fc3
No known key found for this signature in database
GPG Key ID: 179D65BF47E8BD36
9 changed files with 50 additions and 24 deletions

View File

@ -39,7 +39,7 @@ Credits
Contributors
------------
* Siddharth Bhalgami <siddharth.bhalgami@techreceptives.com>
* Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
* Kaushal Prajapati <kbprajapati@live.com>
Maintainer

View File

@ -0,0 +1,4 @@
# Copyright 2019 Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import models

View File

@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@techreceptives.com>
# Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Web Widget - Image WebCam",
"summary": "Allows to take image with WebCam",
"version": "10.0.1.0.0",
"version": "11.0.1.0.0",
"category": "web",
"website": "https://www.techreceptives.com",
"website": "https://github.com/OCA/web",
"author": "Tech Receptives, "
"Odoo Community Association (OCA), "
"Kaushal Prajapati",

View File

@ -0,0 +1,4 @@
# Copyright 2019 Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import ir_config_parameter

View File

@ -0,0 +1,14 @@
# Copyright 2019 Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo.models import api, Model
class IrConfigParameter(Model):
_inherit = "ir.config_parameter"
@api.model
def get_webcam_flash_fallback_mode_config(self):
return self.sudo().get_param(
'web_widget_image_webcam.flash_fallback_mode',
default=False)

View File

@ -1,5 +1,5 @@
/*
Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@techreceptives.com>
Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
*/
.o_form_view.o_form_editable .o_form_field_image .o_form_image_controls

View File

@ -1,20 +1,21 @@
/*
Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@techreceptives.com>
Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
*/
odoo.define('web_widget_image_webcam.webcam_widget', function(require) {
"use strict";
var core = require('web.core');
var Model = require('web.Model');
var rpc = require('web.rpc');
var Dialog = require('web.Dialog');
var FieldBinaryImage = require('web.basic_fields').FieldBinaryImage;
var _t = core._t;
var QWeb = core.qweb;
core.form_widget_registry.get("image").include({
FieldBinaryImage.include({
render_value: function () {
_render: function () {
this._super();
var self = this,
@ -35,10 +36,10 @@ odoo.define('web_widget_image_webcam.webcam_widget', function(require) {
swfURL: '/web_widget_image_webcam/static/src/js/webcam.swf',
});
self.$el.find('.o_form_binary_file_web_cam').removeClass('col-md-offset-5');
new Model('ir.config_parameter').call('get_param', ['web_widget_image_webcam.flash_fallback_mode', false]).
then(function(default_flash_fallback_mode) {
rpc.query({
model: 'ir.config_parameter',
method: 'get_webcam_flash_fallback_mode_config',
}).then(function(default_flash_fallback_mode) {
if (default_flash_fallback_mode == 1) {
Webcam.set({
/*
@ -52,7 +53,7 @@ odoo.define('web_widget_image_webcam.webcam_widget', function(require) {
self.$el.find('.o_form_binary_file_web_cam').off().on('click', function(){
// Init Webcam
new Dialog(self, {
var dialog = new Dialog(self, {
size: 'large',
dialogClass: 'o_act_window',
title: _t("WebCam Booth"),
@ -66,8 +67,10 @@ odoo.define('web_widget_image_webcam.webcam_widget', function(require) {
// Display Snap besides Live WebCam Preview
WebCamDialog.find("#webcam_result").html('<img src="'+img_data+'"/>');
});
// Remove "disabled" attr from "Save & Close" button
$('.save_close_btn').removeAttr('disabled');
if (Webcam.live) {
// Remove "disabled" attr from "Save & Close" button
$('.save_close_btn').removeAttr('disabled');
}
}
},
{
@ -100,13 +103,15 @@ odoo.define('web_widget_image_webcam.webcam_widget', function(require) {
]
}).open();
Webcam.attach('#live_webcam');
dialog.opened().then(function() {
Webcam.attach('#live_webcam');
// At time of Init "Save & Close" button is disabled
$('.save_close_btn').attr('disabled', 'disabled');
// At time of Init "Save & Close" button is disabled
$('.save_close_btn').attr('disabled', 'disabled');
// Placeholder Image in the div "webcam_result"
WebCamDialog.find("#webcam_result").html('<img src="/web_widget_image_webcam/static/src/img/webcam_placeholder.png"/>');
// Placeholder Image in the div "webcam_result"
WebCamDialog.find("#webcam_result").html('<img src="/web_widget_image_webcam/static/src/img/webcam_placeholder.png"/>');
});
});
},
});

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@techreceptives.com>
<!-- Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<template id="template" xml:space="preserve">

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@techreceptives.com>
<!-- Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<template id="assets_backend" inherit_id="web.assets_backend">