From 03618d35023b1e85bd27f7424c576848de04145e Mon Sep 17 00:00:00 2001 From: MeetSCS Date: Tue, 1 Dec 2015 14:35:11 +0530 Subject: [PATCH] Removed v8 modules. Migrated digital sign and one2many kanban Added Lib for digital sign module. Fixed the issue of xpath ref #45. --- web_digital_sign/LICENSE/LICENSE | 17 +++++ web_digital_sign/__init__.py | 22 +------ web_digital_sign/__openerp__.py | 24 +------ .../static/src/js/digital_sign.js | 65 +++++++++++-------- web_digital_sign/users.py | 23 +------ web_digital_sign/users_view.xml | 16 ++--- 6 files changed, 67 insertions(+), 100 deletions(-) create mode 100644 web_digital_sign/LICENSE/LICENSE diff --git a/web_digital_sign/LICENSE/LICENSE b/web_digital_sign/LICENSE/LICENSE new file mode 100644 index 00000000..ab881729 --- /dev/null +++ b/web_digital_sign/LICENSE/LICENSE @@ -0,0 +1,17 @@ + OpenERP, Open Source Management Solution + Copyright (C) 2004-2010 OpenERP SA () + Copyright (C) 2011-2015 Serpent Consulting Services Pvt. Ltd. (). + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + 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 for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + diff --git a/web_digital_sign/__init__.py b/web_digital_sign/__init__.py index e14f6294..1656f744 100644 --- a/web_digital_sign/__init__.py +++ b/web_digital_sign/__init__.py @@ -1,24 +1,4 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 OpenERP SA () -# Copyright (C) 2011-2015 Serpent Consulting Services Pvt. Ltd. (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# 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 for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - +# Part of Odoo. See LICENSE file for full copyright and licensing details. import users # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/web_digital_sign/__openerp__.py b/web_digital_sign/__openerp__.py index 687ce325..a2f39803 100644 --- a/web_digital_sign/__openerp__.py +++ b/web_digital_sign/__openerp__.py @@ -1,27 +1,7 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 OpenERP SA () -# Copyright (C) 2011-2015 Serpent Consulting Services Pvt. Ltd. (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# 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 for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - +# Part of Odoo. See LICENSE file for full copyright and licensing details. { - "name" : "Web Digital Signature", + "name" : "Web Digital Signature 9.0", "version" : "1.0", "author" : "Serpent Consulting Services Pvt. Ltd.", "category": '', diff --git a/web_digital_sign/static/src/js/digital_sign.js b/web_digital_sign/static/src/js/digital_sign.js index 8fc0bfb5..1363b93d 100644 --- a/web_digital_sign/static/src/js/digital_sign.js +++ b/web_digital_sign/static/src/js/digital_sign.js @@ -1,19 +1,25 @@ -openerp.web_digital_sign = function(instance) { - var _t = instance.web._t; - var QWeb = instance.web.qweb; - var images = {} +odoo.define('web_digital_sign.web_digital_sign',function(require){ + "use strict"; - instance.web.form.widgets.add('signature', 'instance.web.form.FieldSignature'); - instance.web.form.FieldSignature = instance.web.form.FieldBinaryImage.extend({ + var core = require('web.core'); + var data = require('web.data'); + var FormView = require('web.FormView'); + var utils = require('web.utils'); + + var _t = core._t; + var QWeb = core.qweb; + var images = {}; + + var FieldSignature = core.form_widget_registry.map.image.extend({ template: 'FieldSignature', render_value: function() { var self = this; var url; - if (this.get('value') && !instance.web.form.is_bin_size(this.get('value'))) { + if (this.get('value') && ! utils.is_bin_size(this.get('value'))) { url = 'data:image/png;base64,' + this.get('value'); }else if (this.get('value')) { var id = JSON.stringify(this.view.datarecord.id || null); - self.digita_dataset = new instance.web.DataSetSearch(self, self.view.model, {}, []); + self.digita_dataset = new data.DataSetSearch(self, self.view.model, {}, []); self.digita_dataset.read_slice(['id', self.name], {'domain': [['id', '=', id]]}).then(function(records){ _.each(records,function(record){ if(record[self.name]){ @@ -67,7 +73,7 @@ openerp.web_digital_sign = function(instance) { $(self.$el[0]).find(".signature").show(); $(self.$el[0]).find(".signature").signature('clear'); }); - $('.save_sign').click(function(){ + $(this.$el[0]).find('.save_sign').on('click',function(){ var val if($(self.$el[0]).find(".signature").hasClass( "kbw-signature" ) && ! $(self.$el[0]).find(".signature").signature('isEmpty')){ $(self.$el[0]).find(".signature").hide(); @@ -86,18 +92,18 @@ openerp.web_digital_sign = function(instance) { t: (new Date().getTime()), }); }else{ - var id = JSON.stringify(self.view.datarecord.id || null); - var field = self.name; - if (self.options.preview_image) - field = self.options.preview_image; - url = self.session.url('/web/binary/image', { - model: self.view.dataset.model, - id: id, - field: field, - t: (new Date().getTime()), - }); - var $img = $(QWeb.render("FieldBinaryImage-extend", { widget: self, url: url })); - self.$el.find('> img').remove(); + var id = JSON.stringify(self.view.datarecord.id || null); + var field = self.name; + if (self.options.preview_image) + field = self.options.preview_image; + url = self.session.url('/web/binary/image', { + model: self.view.dataset.model, + id: id, + field: field, + t: (new Date().getTime()), + }); + var $img = $(QWeb.render("FieldBinaryImage-extend", { widget: self, url: url })); + self.$el.find('> img').remove(); } }); $img.load(function() { @@ -109,24 +115,29 @@ openerp.web_digital_sign = function(instance) { $img.css("margin-top", "" + (self.options.size[1] - $img.height()) / 2 + "px"); }); $img.on('error', function() { + console.log("eroor") $img.attr('src', self.placeholder); - instance.webclient.notification.warn(_t("Image"), _t("Could not display the selected image.")); + self.do_warn(_t("Image"), _t("Could not display the selected image.")); }); }, }); - instance.web.FormView.include({ + + core.form_widget_registry.add('signature', FieldSignature) + + FormView.include({ save: function(prepend_on_create) { var self = this; $('.save_sign').click() var save_obj = {prepend_on_create: prepend_on_create, ret: null}; this.save_list.push(save_obj); - return this._process_operations().then(function() { + return self._process_operations().then(function() { if (save_obj.error) return $.Deferred().reject(); return $.when.apply($, save_obj.ret); - }).done(function() { + }).done(function(result) { self.$el.removeClass('oe_form_dirty'); }); }, - }) -} + }); + +}); diff --git a/web_digital_sign/users.py b/web_digital_sign/users.py index 20486b62..92e6e1ef 100644 --- a/web_digital_sign/users.py +++ b/web_digital_sign/users.py @@ -1,24 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 OpenERP SA () -# Copyright (C) 2011-2015 Serpent Consulting Services Pvt. Ltd. (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# 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 for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# Part of Odoo. See LICENSE file for full copyright and licensing details. from openerp import models, fields, api @@ -26,6 +7,6 @@ class Users(models.Model): _name = 'res.users' _inherit = 'res.users' - signature_image= fields.Binary(string='Signature') + signature= fields.Binary(string='Signature') # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/web_digital_sign/users_view.xml b/web_digital_sign/users_view.xml index ef0c0d8f..8c7cc427 100644 --- a/web_digital_sign/users_view.xml +++ b/web_digital_sign/users_view.xml @@ -1,18 +1,16 @@ - - - + + inherited.res.users.form res.users - - + + - - + \ No newline at end of file