diff --git a/web_widget_timepicker/README.rst b/web_widget_timepicker/README.rst
index fa64c2df..b3b474c5 100644
--- a/web_widget_timepicker/README.rst
+++ b/web_widget_timepicker/README.rst
@@ -12,10 +12,9 @@ definition. It can be use as a replacement for the standard float_time widget.
If you use the widget with a field record, the input field has the following default
timepicker options:
-* 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
+* By default the possible selection is based on 15 minute interval (step: 15)
+* By default 24 hour mode with H:i format (timeFormat: 'H:i')
+* By default scroll selection starts at current time (scrollDefault: 'now')
The widget uses the jquery.timepicker plugin by Jon Thornton
@@ -24,22 +23,21 @@ Usage
=====
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::
+You can pass custom options through the "timepicker" field in the options attribute:
...
-
+
...
-See the available options at https://github.com/jonthornton/jquery-timepicker#timepicker-plugin-for-jquery
+See the available options at https://github.com/jonthornton/jquery-timepicker#timepicker-plugin-for-jquery.
-ToDo
-====
+Known issues / Roadmap
+======================
-Sanity check on options available in field defintion as override options for timepicker widget.
+* Absolutely no sanity check or validation on options.
Credits
diff --git a/web_widget_timepicker/__openerp__.py b/web_widget_timepicker/__openerp__.py
index 251486cc..d2cdeb42 100644
--- a/web_widget_timepicker/__openerp__.py
+++ b/web_widget_timepicker/__openerp__.py
@@ -10,7 +10,6 @@
'category': 'Web',
'website': 'https://github.com/OCA/Web',
- # any module necessary for this one to work correctly
'depends': [
'web'
],
@@ -25,12 +24,9 @@
'qweb': [
'static/src/xml/web_widget_timepicker.xml'
],
-
- # always loaded
'data': [
'views/web_widget_timepicker_assets.xml'
],
- # Installation options
"installable": True,
}
diff --git a/web_widget_timepicker/static/src/js/web_widget_timepicker.js b/web_widget_timepicker/static/src/js/web_widget_timepicker.js
index 4db68f30..b56a8cf4 100644
--- a/web_widget_timepicker/static/src/js/web_widget_timepicker.js
+++ b/web_widget_timepicker/static/src/js/web_widget_timepicker.js
@@ -1,20 +1,11 @@
-odoo.define('web_widget_timepicker.form_widgets', function (require) {
+odoo.define('web_widget_timepicker', function (require) {
"use strict";
var core = require('web.core');
var formats = require('web.formats');
var common = require('web.form_common');
- // Snippet from http://stackoverflow.com/questions/9036429/convert-object-string-to-json
- function cleanup_str2json(str) {
- return (str.length > 0 && str !== undefined) ? str
- // wrap keys without quote with valid double quote
- .replace(/([\$\w]+)\s*:/g, function(_, $1){return '"'+$1+'":'})
- // replacing single quote wrapped ones to double quote
- .replace(/'([^']+)'/g, function(_, $1){return '"'+$1+'"'}) : undefined;
- };
-
- var TimePicker = common.AbstractField.extend(common.ReinitializeFieldMixin, {
+ var TimePickerField = common.AbstractField.extend(common.ReinitializeFieldMixin, {
is_field_number: true,
template: "TimePickerField",
internal_format: 'float_time',
@@ -27,9 +18,7 @@ odoo.define('web_widget_timepicker.form_widgets', function (require) {
this.internal_set_value(0);
- this.options = _.defaults( {}, {
- disableTextInput: true,
- forceRoundTime: true,
+ this.options = _.defaults( this.options, {
step: 15,
selectOnBlur: true,
timeFormat: 'H:i',
@@ -38,24 +27,7 @@ odoo.define('web_widget_timepicker.form_widgets', function (require) {
},
initialize_content: function() {
if(!this.get("effective_readonly")) {
- var custom_options;
-
- if( this.node.attrs['data-options'] !== undefined && this.node.attrs['data-options'].length > 0) {
- // First try to use jquery data function to create object
- custom_options = $(this.node).data('options');
-
- if(typeof custom_options !== 'object') {
- // No garantee that the input data-options string is valid JSON format so try to cleanup
- custom_options = JSON.parse(cleanup_str2json(this.node.attrs['data-options']));
- }
- }
-
- if(typeof custom_options === 'object') {
- this.$el.find('input').timepicker($.extend({}, this.options, custom_options ));
- } else {
- this.$el.find('input').timepicker(this.options);
- }
-
+ this.$el.find('input').timepicker(this.options);
this.setupFocus(this.$('input'));
}
},
@@ -109,7 +81,9 @@ odoo.define('web_widget_timepicker.form_widgets', function (require) {
},
});
- core.form_widget_registry.add('timepicker', TimePicker);
+ core.form_widget_registry.add('timepicker', TimePickerField);
- return TimePicker;
+ return {
+ TimePickerField: TimePickerField,
+ };
});