Browse Source

[11.0][MIG] web_widget_image_webcam: code migration

pull/964/head
Siddharth Bhalgami 5 years ago
parent
commit
0867342fc9
No known key found for this signature in database GPG Key ID: 179D65BF47E8BD36
  1. 2
      web_widget_image_webcam/README.rst
  2. 4
      web_widget_image_webcam/__init__.py
  3. 7
      web_widget_image_webcam/__manifest__.py
  4. 4
      web_widget_image_webcam/models/__init__.py
  5. 14
      web_widget_image_webcam/models/ir_config_parameter.py
  6. 2
      web_widget_image_webcam/static/src/css/web_widget_image_webcam.css
  7. 37
      web_widget_image_webcam/static/src/js/webcam_widget.js
  8. 2
      web_widget_image_webcam/static/src/xml/web_widget_image_webcam.xml
  9. 2
      web_widget_image_webcam/views/assets.xml

2
web_widget_image_webcam/README.rst

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

4
web_widget_image_webcam/__init__.py

@ -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

7
web_widget_image_webcam/__manifest__.py

@ -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",

4
web_widget_image_webcam/models/__init__.py

@ -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

14
web_widget_image_webcam/models/ir_config_parameter.py

@ -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)

2
web_widget_image_webcam/static/src/css/web_widget_image_webcam.css

@ -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

37
web_widget_image_webcam/static/src/js/webcam_widget.js

@ -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"/>');
});
});
},
});

2
web_widget_image_webcam/static/src/xml/web_widget_image_webcam.xml

@ -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">

2
web_widget_image_webcam/views/assets.xml

@ -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">

Loading…
Cancel
Save