diff --git a/web_widget_timepicker/README.rst b/web_widget_timepicker/README.rst
index 5292b140..3f6bf12c 100644
--- a/web_widget_timepicker/README.rst
+++ b/web_widget_timepicker/README.rst
@@ -5,19 +5,19 @@
Timepicker widget in form view
==============================
-This module defines a timepicker widget, to be used with either char fields
-or (function) fields of type character. Use ``widget='timepicker'`` in your form view
-definition.
+This module defines a timepicker widget, to be used with float fields
+or (function) fields. Use ``widget='timepicker'`` in your form view
+definition. It can be use as a replacement for the standard float_time widget.
-If you use the widget with a character field, the input field has the following default
+If you use the widget with a field record, the input field has the following default
timepicker options:
-* By default direct input is disabled
+* By default direct user input is disabled
* By default the possible selection is based on 15 minute interval
* By default 24 hour mode with H:i format
* Scroll selection defaults to current server time
-The widget uses the jquery.timepicker plugin by Jon Thornton
+The widget uses the jquery.timepicker plugin by Jon Thornton
Usage
@@ -27,17 +27,25 @@ This module defines a new widget type for form views input fileds.
Set the attribute ``widget=timepicker`` in a ``field`` tag in a form view.
+You can pass all options through the "timepicker" field in the options::
+
+ ...
+
+ ...
+
+See the available options at https://github.com/jonthornton/jquery-timepicker#timepicker-plugin-for-jquery
+
ToDo
====
-Make timepicker options available in field defintion as additional attributes / options.
+Sanity check on options available in field defintion as override options for timepicker widget.
Credits
=======
-Jon Thornton (jquery.timepicker plugin)
+Jon Thornton (https://cdnjs.com/libraries/jquery-timepicker)
jquery.timepicker plugin - This software is made available under the open source MIT License. © 2014 Jon Thornton and contributors
Odoo Community Association (OCA)
diff --git a/web_widget_timepicker/__init__.py b/web_widget_timepicker/__init__.py
index 96d91e91..ea2c0d3a 100644
--- a/web_widget_timepicker/__init__.py
+++ b/web_widget_timepicker/__init__.py
@@ -1,22 +1,2 @@
# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2015 BADEP ().
-#
-# 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 .
-#
-##############################################################################
-
-
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
\ No newline at end of file
diff --git a/web_widget_timepicker/__openerp__.py b/web_widget_timepicker/__openerp__.py
index faf3eeec..fb091f39 100644
--- a/web_widget_timepicker/__openerp__.py
+++ b/web_widget_timepicker/__openerp__.py
@@ -1,49 +1,34 @@
# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2016 Michael Fried @ Vividlab ().
-#
-# 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 .
-#
-##############################################################################
-
+# © 2016 Michael Fried @ Vividlab ()
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
- 'name': '',
- 'version': '0.1',
- 'author': 'Vividlab, Odoo Community Association (OCA)',
+ 'name': 'Web Timepicker Widget',
+ 'version': '9.0.1.0.0',
+ 'author': 'Michael Fried@Vividlab, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'category': 'Web',
'website': 'https://github.com/OCA/Web',
# any module necessary for this one to work correctly
'depends': [
- 'web'
+ 'web'
+ ],
+ 'css': [
+ 'static/src/lib/jquery.timerpicker/jquery.timepicker.css',
+ 'static/src/css/web_widget_timepicker.css'
+ ],
+ 'js': [
+ 'static/src/lib/jquery.timerpicker/jquery.timepicker.js',
+ 'static/src/js/web_widget_timepicker.js',
+ ],
+ 'qweb' : [
+ 'static/src/xml/web_widget_timepicker.xml'
],
-
- 'css': [ 'static/src/css/jquery.timepicker.css',
- 'static/src/css/timepicker.css',
- ],
- 'js': [ 'static/src/js/timepicker_widget.js',
- 'static/src/js/jquery.timepicker.js',
- ],
- 'qweb' : [ 'static/src/xml/time_picker.xml', ],
# always loaded
'data': [
- 'views/assets.xml',
+ 'views/web_widget_timepicker_assets.xml'
],
#Installation options
diff --git a/web_widget_timepicker/static/src/css/timepicker.css b/web_widget_timepicker/static/src/css/web_widget_timepicker.css
similarity index 78%
rename from web_widget_timepicker/static/src/css/timepicker.css
rename to web_widget_timepicker/static/src/css/web_widget_timepicker.css
index 5a22e371..1b29e131 100644
--- a/web_widget_timepicker/static/src/css/timepicker.css
+++ b/web_widget_timepicker/static/src/css/web_widget_timepicker.css
@@ -1,3 +1,3 @@
.oe_form_editable .oe_form .oe_form_field_time input {
- width: 7em;
+ width: 6em;
}
diff --git a/web_widget_timepicker/static/src/js/timepicker_widget.js b/web_widget_timepicker/static/src/js/web_widget_timepicker.js
similarity index 57%
rename from web_widget_timepicker/static/src/js/timepicker_widget.js
rename to web_widget_timepicker/static/src/js/web_widget_timepicker.js
index 898b3a82..d72aea44 100644
--- a/web_widget_timepicker/static/src/js/timepicker_widget.js
+++ b/web_widget_timepicker/static/src/js/web_widget_timepicker.js
@@ -1,21 +1,22 @@
-odoo.define('timepicker.form_widgets', function (require) {
-
+odoo.define('web_widget_timepicker.form_widgets', function (require) {
"use strict";
var core = require('web.core');
var formats = require('web.formats');
var common = require('web.form_common');
- var _t = core._t;
-
var TimePicker = common.AbstractField.extend(common.ReinitializeFieldMixin, {
+ is_field_number: true,
template: "TimePickerField",
+ internal_format: 'float_time',
widget_class: 'oe_form_field_time',
events: {
'change input': 'store_dom_value',
},
init: function (field_manager, node) {
this._super(field_manager, node);
+
+ this.internal_set_value(0);
this.options = _.defaults( {}, {
disableTextInput: true,
@@ -29,14 +30,45 @@ odoo.define('timepicker.form_widgets', function (require) {
initialize_content: function() {
if(!this.get("effective_readonly")) {
this.$input = this.$el.find('input');
- this.$input.timepicker(this.options);
+
+ var effective_options = this.options;
+
+ if(typeof this.node.attrs.options !== 'undefined' && this.node.attrs.options.length > 0 ) {
+
+ var custom_options = eval('('+ this.node.attrs.options +')')
+
+ // for(var key in custom_options) {
+ // console.log('attr key : ' + key);
+ // console.log('attr value : ' + custom_options[key] );
+ // }
+
+ // if(typeof effective_options === 'object') {
+ // for(var key in effective_options) {
+ // console.log('def key : ' + key);
+ // console.log('def value : ' + effective_options[key] );
+ // }
+ // }
+
+ if(typeof custom_options === 'object') {
+ effective_options = $.extend({}, this.options, custom_options );
+ }
+
+ // if(typeof effective_options === 'object') {
+ // for(var key in effective_options) {
+ // console.log('merge key : ' + key);
+ // console.log('merge value : ' + effective_options[key] );
+ // }
+ // }
+ }
+
+ this.$input.timepicker(effective_options);
this.setupFocus(this.$('input'));
}
},
is_syntax_valid: function() {
if (!this.get("effective_readonly") && this.$("input").size() > 0) {
try {
- this.parse_value(this.$('input').val(), '');
+ this.parse_value(this.$('input').val(),'');
return true;
} catch(e) {
return false;
@@ -62,17 +94,17 @@ odoo.define('timepicker.form_widgets', function (require) {
if (!this.get('effective_readonly')) {
this.internal_set_value(
this.parse_value(
- this.$('input').val()));
+ this.$('input').val(),''));
}
},
parse_value: function(val, def) {
- return formats.parse_value(val, this, def);
+ return formats.parse_value(val, {"widget": this.internal_format}, def);
},
format_value: function(val, def) {
- return formats.format_value(val, this, def);
+ return formats.format_value(val, {"widget": this.internal_format}, def);
},
render_value: function() {
- var show_value = this.format_value(this.get('value'), '');
+ var show_value = this.format_value(this.get('value'),'');
if (!this.get("effective_readonly")) {
this.$input = this.$el.find('input');
diff --git a/web_widget_timepicker/static/src/css/jquery.timepicker.css b/web_widget_timepicker/static/src/lib/jquery.timepicker/jquery.timepicker.css
similarity index 100%
rename from web_widget_timepicker/static/src/css/jquery.timepicker.css
rename to web_widget_timepicker/static/src/lib/jquery.timepicker/jquery.timepicker.css
diff --git a/web_widget_timepicker/static/src/js/jquery.timepicker.js b/web_widget_timepicker/static/src/lib/jquery.timepicker/jquery.timepicker.js
similarity index 100%
rename from web_widget_timepicker/static/src/js/jquery.timepicker.js
rename to web_widget_timepicker/static/src/lib/jquery.timepicker/jquery.timepicker.js
diff --git a/web_widget_timepicker/static/src/xml/time_picker.xml b/web_widget_timepicker/static/src/xml/web_widget_timepicker.xml
similarity index 98%
rename from web_widget_timepicker/static/src/xml/time_picker.xml
rename to web_widget_timepicker/static/src/xml/web_widget_timepicker.xml
index 4bd8eef2..b8da8f19 100644
--- a/web_widget_timepicker/static/src/xml/time_picker.xml
+++ b/web_widget_timepicker/static/src/xml/web_widget_timepicker.xml
@@ -1,5 +1,4 @@
-
@@ -18,4 +17,4 @@
-
+
\ No newline at end of file
diff --git a/web_widget_timepicker/views/assets.xml b/web_widget_timepicker/views/web_widget_timepicker_assets.xml
similarity index 51%
rename from web_widget_timepicker/views/assets.xml
rename to web_widget_timepicker/views/web_widget_timepicker_assets.xml
index 91731df5..a2ef2905 100644
--- a/web_widget_timepicker/views/assets.xml
+++ b/web_widget_timepicker/views/web_widget_timepicker_assets.xml
@@ -2,13 +2,13 @@
-
+
-
-
-
-
+
+
+
+
-
+
\ No newline at end of file