From a858942e8fcff90e64138acc221426cc84ae489a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Faure-Lacroix?= Date: Thu, 3 Dec 2015 21:06:37 +0300 Subject: [PATCH 1/6] Made web_widget_color installable and remove the search field. The search field doesn't seem to exist anymore --- web_widget_color/__openerp__.py | 2 +- web_widget_color/static/src/js/widget.js | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/web_widget_color/__openerp__.py b/web_widget_color/__openerp__.py index 2a20bfaf..50838cc8 100644 --- a/web_widget_color/__openerp__.py +++ b/web_widget_color/__openerp__.py @@ -39,6 +39,6 @@ 'static/src/xml/widget.xml', ], 'auto_install': False, - 'installable': False, + 'installable': True, 'web_preload': True, } diff --git a/web_widget_color/static/src/js/widget.js b/web_widget_color/static/src/js/widget.js index 44299752..5c2d2c21 100644 --- a/web_widget_color/static/src/js/widget.js +++ b/web_widget_color/static/src/js/widget.js @@ -11,8 +11,6 @@ openerp.web_widget_color = function (instance) { instance.web.form.widgets.add('color', 'instance.web.form.FieldColor'); - instance.web.search.fields.add('color', 'instance.web.search.CharField'); - instance.web.form.FieldColor = instance.web.form.FieldChar.extend({ template: 'FieldColor', widget_class: 'oe_form_field_color', From 954baadc44a9ac715b9eee82c5e26efb2594f68d Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Wed, 13 Jan 2016 09:17:26 +0100 Subject: [PATCH 2/6] fix: update to new js api - Force store_dom_value - add clean colored square in tree view - update readme and __openerp__.py for maintainers --- web_widget_color/README.rst | 1 + web_widget_color/__openerp__.py | 1 + web_widget_color/static/src/css/widget.css | 7 ++++ web_widget_color/static/src/js/widget.js | 39 ++++++++++++++++++---- web_widget_color/static/src/xml/widget.xml | 2 +- 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/web_widget_color/README.rst b/web_widget_color/README.rst index a163f899..ad79a61a 100644 --- a/web_widget_color/README.rst +++ b/web_widget_color/README.rst @@ -87,6 +87,7 @@ Contributors ------------ * Adil Houmadi +* Nicolas JEUDY (Sudokeys) Maintainer ---------- diff --git a/web_widget_color/__openerp__.py b/web_widget_color/__openerp__.py index 50838cc8..74e7a798 100644 --- a/web_widget_color/__openerp__.py +++ b/web_widget_color/__openerp__.py @@ -30,6 +30,7 @@ "author": "Savoir-faire Linux, " "Anybox, " "Taktik SA, " + "Sudokeys, " "Odoo Community Association (OCA)", 'depends': ['base', 'web'], 'data': [ diff --git a/web_widget_color/static/src/css/widget.css b/web_widget_color/static/src/css/widget.css index 06201af1..9a701ad1 100644 --- a/web_widget_color/static/src/css/widget.css +++ b/web_widget_color/static/src/css/widget.css @@ -21,3 +21,10 @@ top: 3px; width: 40px; } + +.color_box { + width: 10px; + height: 10px; + display: inline-block; + margin-right: 5px; +} diff --git a/web_widget_color/static/src/js/widget.js b/web_widget_color/static/src/js/widget.js index 5c2d2c21..aad55279 100644 --- a/web_widget_color/static/src/js/widget.js +++ b/web_widget_color/static/src/js/widget.js @@ -1,4 +1,12 @@ -openerp.web_widget_color = function (instance) { +odoo.define('web.web_widget_color', function(require) { + "use strict"; + + var core = require('web.core'); + var widget = require('web.form_widgets'); + var FormView = require('web.FormView'); + + var QWeb = core.qweb; + var _lt = core._lt; var _super_getDir = jscolor.getDir.prototype; jscolor.getDir = function () { @@ -9,9 +17,7 @@ openerp.web_widget_color = function (instance) { return jscolor.dir; }; - instance.web.form.widgets.add('color', 'instance.web.form.FieldColor'); - - instance.web.form.FieldColor = instance.web.form.FieldChar.extend({ + var FieldColor = widget.FieldChar.extend({ template: 'FieldColor', widget_class: 'oe_form_field_color', is_syntax_valid: function () { @@ -31,6 +37,21 @@ openerp.web_widget_color = function (instance) { } return true; }, + store_dom_value: function() { + if (!this.silent) { + if (!this.get('effective_readonly') && + this.$('input').val() !== '' && + this.is_syntax_valid()) { + // We use internal_set_value because we were called by + // ``.commit_value()`` which is called by a ``.set_value()`` + // itself called because of a ``onchange`` event + this.internal_set_value( + this.parse_value( + this.$('input').val()) + ); + } + } + }, render_value: function () { var show_value = this.format_value(this.get('value'), ''); if (!this.get("effective_readonly")) { @@ -45,13 +66,19 @@ openerp.web_widget_color = function (instance) { } }); + core.form_widget_registry.add('color', FieldColor); + /* * Init jscolor for each editable mode on view form */ - instance.web.FormView.include({ + FormView.include({ to_edit_mode: function () { this._super(); jscolor.init(this.$el[0]); } }); -}; + + return { + FieldColor: FieldColor + }; +}); diff --git a/web_widget_color/static/src/xml/widget.xml b/web_widget_color/static/src/xml/widget.xml index c62ae1cf..82c043b4 100644 --- a/web_widget_color/static/src/xml/widget.xml +++ b/web_widget_color/static/src/xml/widget.xml @@ -19,6 +19,6 @@ -
+
From e4360655a80791550704dbf84e9d143a5e5596be Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Tue, 9 Aug 2016 09:47:43 +0200 Subject: [PATCH 3/6] short headers, bump up version number --- web_widget_color/README.rst | 6 ------ web_widget_color/__init__.py | 23 ----------------------- web_widget_color/__openerp__.py | 22 ++-------------------- 3 files changed, 2 insertions(+), 49 deletions(-) diff --git a/web_widget_color/README.rst b/web_widget_color/README.rst index ad79a61a..5cf105a9 100644 --- a/web_widget_color/README.rst +++ b/web_widget_color/README.rst @@ -27,12 +27,6 @@ Features |listview| -Requirements -============ - -This module has been ported to 8.0 - - Usage ===== diff --git a/web_widget_color/__init__.py b/web_widget_color/__init__.py index c18661e9..cb28fbd1 100644 --- a/web_widget_color/__init__.py +++ b/web_widget_color/__init__.py @@ -1,25 +1,2 @@ # -*- encoding: utf-8 -*- -############################################################################ # -# Odoo, Open Source Web Color -# Copyright (C) 2012 Savoir-faire Linux (). -# Copyright (C) 2014 Anybox -# Copyright (C) 2015 Taktik SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# @author Étienne Beaudry Auger -# @author Adil Houmadi -# -############################################################################## diff --git a/web_widget_color/__openerp__.py b/web_widget_color/__openerp__.py index 74e7a798..789c249c 100644 --- a/web_widget_color/__openerp__.py +++ b/web_widget_color/__openerp__.py @@ -1,32 +1,14 @@ # -*- encoding: utf-8 -*- -############################################################################ -# # Odoo, Open Source Web Widget Color # Copyright (C) 2012 Savoir-faire Linux (). # Copyright (C) 2014 Anybox # Copyright (C) 2015 Taktik SA # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# @author Étienne Beaudry Auger -# @author Adil Houmadi -# -############################################################################## +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).# { 'name': "Web Widget Color", 'category': "web", - 'version': "8.0.1.0.0", + 'version': "9.0.1.0.0", "author": "Savoir-faire Linux, " "Anybox, " "Taktik SA, " From a07db58db16afe7f68836e29094a37647cc03424 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Mon, 26 Sep 2016 16:53:47 +0500 Subject: [PATCH 4/6] [FIX] encoding -> coding --- web_widget_color/__init__.py | 2 +- web_widget_color/__openerp__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web_widget_color/__init__.py b/web_widget_color/__init__.py index cb28fbd1..ec51c5a2 100644 --- a/web_widget_color/__init__.py +++ b/web_widget_color/__init__.py @@ -1,2 +1,2 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- # diff --git a/web_widget_color/__openerp__.py b/web_widget_color/__openerp__.py index 789c249c..020b5c7c 100644 --- a/web_widget_color/__openerp__.py +++ b/web_widget_color/__openerp__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- # Odoo, Open Source Web Widget Color # Copyright (C) 2012 Savoir-faire Linux (). # Copyright (C) 2014 Anybox From d947106589037ca670a6bb2dba2d8a911c7b9657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= Date: Wed, 28 Sep 2016 13:46:06 +0200 Subject: [PATCH 5/6] [ADD] setup.py --- setup/web_widget_color/odoo_addons/__init__.py | 1 + setup/web_widget_color/odoo_addons/web_widget_color | 1 + setup/web_widget_color/setup.py | 6 ++++++ 3 files changed, 8 insertions(+) create mode 100644 setup/web_widget_color/odoo_addons/__init__.py create mode 120000 setup/web_widget_color/odoo_addons/web_widget_color create mode 100644 setup/web_widget_color/setup.py diff --git a/setup/web_widget_color/odoo_addons/__init__.py b/setup/web_widget_color/odoo_addons/__init__.py new file mode 100644 index 00000000..de40ea7c --- /dev/null +++ b/setup/web_widget_color/odoo_addons/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/web_widget_color/odoo_addons/web_widget_color b/setup/web_widget_color/odoo_addons/web_widget_color new file mode 120000 index 00000000..76692066 --- /dev/null +++ b/setup/web_widget_color/odoo_addons/web_widget_color @@ -0,0 +1 @@ +../../../web_widget_color \ No newline at end of file diff --git a/setup/web_widget_color/setup.py b/setup/web_widget_color/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/web_widget_color/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From ff37f0306c30191d5ccf709973d4c0cc78244e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= Date: Wed, 28 Sep 2016 13:50:27 +0200 Subject: [PATCH 6/6] [FIX] pylint --- web_widget_color/__openerp__.py | 1 + web_widget_color/static/src/js/widget.js | 4 ++-- .../view/web_widget_color_view.xml | 20 +++++++++---------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/web_widget_color/__openerp__.py b/web_widget_color/__openerp__.py index 020b5c7c..3f2298bf 100644 --- a/web_widget_color/__openerp__.py +++ b/web_widget_color/__openerp__.py @@ -21,6 +21,7 @@ 'qweb': [ 'static/src/xml/widget.xml', ], + 'license': 'AGPL-3', 'auto_install': False, 'installable': True, 'web_preload': True, diff --git a/web_widget_color/static/src/js/widget.js b/web_widget_color/static/src/js/widget.js index aad55279..548eb7a4 100644 --- a/web_widget_color/static/src/js/widget.js +++ b/web_widget_color/static/src/js/widget.js @@ -57,11 +57,11 @@ odoo.define('web.web_widget_color', function(require) { if (!this.get("effective_readonly")) { var $input = this.$el.find('input'); $input.val(show_value); - $input.css("background-color", show_value) + $input.css("background-color", show_value); jscolor.init(this.$el[0]); } else { this.$(".oe_form_char_content").text(show_value); - this.$('div').css("background-color", show_value) + this.$('div').css("background-color", show_value); } } }); diff --git a/web_widget_color/view/web_widget_color_view.xml b/web_widget_color/view/web_widget_color_view.xml index 7c2c8d0f..82300a00 100644 --- a/web_widget_color/view/web_widget_color_view.xml +++ b/web_widget_color/view/web_widget_color_view.xml @@ -1,12 +1,10 @@ - - - - - \ No newline at end of file + + +