diff --git a/web_widget_color/README.rst b/web_widget_color/README.rst
index dfa955c3..439c8fba 100644
--- a/web_widget_color/README.rst
+++ b/web_widget_color/README.rst
@@ -30,16 +30,7 @@ Features
Usage
=====
-You need to declare a char field of at least size 7::
-
- _columns = {
- 'color': fields.char(
- u"Couleur",
- help=u"Toutes couleur valid css, exemple blue ou #f57900"
- ),
- }
-
- OR
+You need to declare a char field::
color = fields.Char(
string="Color",
@@ -53,12 +44,19 @@ In the view declaration, put widget='color' attribute in the field tag::
...
-
...
...
+
+
+
+ ...
.. |picker| image:: ./images/picker.png
.. |formview| image:: ./images/form_view.png
@@ -66,7 +64,7 @@ In the view declaration, put widget='color' attribute in the field tag::
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
- :target: https://runbot.odoo-community.org/runbot/162/10.0
+ :target: https://runbot.odoo-community.org/runbot/162/11.0
Bug Tracker
===========
@@ -83,6 +81,7 @@ Contributors
------------
* Adil Houmadi
+* Enric Tobella
* Nicolas JEUDY (Sudokeys)
Maintainer
diff --git a/web_widget_color/__manifest__.py b/web_widget_color/__manifest__.py
index e90ef2d0..ebcd0f40 100644
--- a/web_widget_color/__manifest__.py
+++ b/web_widget_color/__manifest__.py
@@ -4,11 +4,11 @@
# Copyright (C) 2014 Anybox
# Copyright (C) 2015 Taktik SA
#
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).#
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).#
{
'name': "Web Widget Color",
'category': "web",
- 'version': "10.0.1.0.0",
+ 'version': "11.0.1.0.0",
"author": "Savoir-faire Linux, "
"Anybox, "
"Taktik SA, "
diff --git a/web_widget_color/static/lib/jscolor/jscolor.js b/web_widget_color/static/lib/jscolor/jscolor.js
index d56e1839..659ab208 100644
--- a/web_widget_color/static/lib/jscolor/jscolor.js
+++ b/web_widget_color/static/lib/jscolor/jscolor.js
@@ -2,7 +2,7 @@
* jscolor, JavaScript Color Picker
*
* @version 1.4.4
- * @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html
+ * @license GNU Lesser General Public License, https://www.gnu.org/copyleft/lesser.html
* @author Jan Odvarko, http://odvarko.cz
* @created 2008-06-15
* @updated 2014-12-09
diff --git a/web_widget_color/static/src/js/widget.js b/web_widget_color/static/src/js/widget.js
index 589ff364..98a19c17 100644
--- a/web_widget_color/static/src/js/widget.js
+++ b/web_widget_color/static/src/js/widget.js
@@ -1,88 +1,53 @@
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 basic_fields = require('web.basic_fields');
+ var field_registry = require('web.field_registry');
+ var FormController = require('web.FormController');
+ var field_utils = require('web.field_utils');
var _super_getDir = jscolor.getDir.prototype;
jscolor.getDir = function () {
var dir = _super_getDir.constructor();
if (dir.indexOf('web_widget_color') === -1) {
- jscolor.dir = 'web_widget_color/static/lib/jscolor/';
+ jscolor.dir = '/web_widget_color/static/lib/jscolor/';
}
return jscolor.dir;
};
- var FieldColor = widget.FieldChar.extend({
+ var FieldColor = basic_fields.FieldChar.extend({
template: 'FieldColor',
widget_class: 'oe_form_field_color',
- is_syntax_valid: function () {
- var $input = this.$('input');
- if (!this.get("effective_readonly") && $input.size() > 0) {
- var val = $input.val();
- var isOk = /^#[0-9A-F]{6}$/i.test(val);
- if (!isOk) {
- return false;
- }
- try {
- this.parse_value(this.$('input').val(), '');
- return true;
- } catch (e) {
- return false;
- }
- }
- return true;
+ _getValue: function() {
+ return field_utils.format.char(this.$('input').val());
},
- 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")) {
+ _render: function () {
+ var show_value = field_utils.format.char(this.value);
+ jscolor.init(this.$el[0]);
+ if (this.mode !== 'readonly') {
var $input = this.$el.find('input');
$input.val(show_value);
$input.css("background-color", show_value);
- jscolor.init(this.$el[0]);
+ this.$input = $input;
+ this.$(".oe_form_char_content").text(show_value);
+ this.$('span').css("background-color", show_value);
} else {
this.$(".oe_form_char_content").text(show_value);
this.$('span').css("background-color", show_value);
+
}
}
});
-
- core.form_widget_registry.add('color', FieldColor);
+ field_registry.add('color', FieldColor);
/*
* Init jscolor for each editable mode on view form
*/
- FormView.include({
- on_button_edit: function () {
- this._super();
- jscolor.init(this.$el[0]);
- },
- on_button_create: function () {
- this._super();
+ FormController.include({
+ _updateEnv : function (parentID) {
+ this._super(parentID);
jscolor.init(this.$el[0]);
}
});
-
- return {
- FieldColor: FieldColor
- };
+ return FieldColor
});
diff --git a/web_widget_color/static/src/xml/widget.xml b/web_widget_color/static/src/xml/widget.xml
index 82c043b4..6112ab43 100644
--- a/web_widget_color/static/src/xml/widget.xml
+++ b/web_widget_color/static/src/xml/widget.xml
@@ -1,18 +1,16 @@
-
-
+
-
-
+ class="color {hash:true} o_input"
+ t-if="widget.mode !== 'readonly'"/>
+