ADD web_datetime_options

pull/101/head
Vincent Vinet 2015-03-23 09:04:19 -04:00
parent 825443eace
commit 34232639da
3 changed files with 72 additions and 0 deletions

View File

View File

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
{
"name": 'web_datetime_options',
"version": "0.1",
"description": """
===========================================
Allow passing options to datepicker widgets
===========================================
This will set all options specified in the "datepicker" option of datetime
fields to the datepicker.
See http://api.jqueryui.com/datepicker/ for options
Example:
--------
<field name="birthdate" options="{'datepicker':{'yearRange': 'c-100:c+0'}}"/>
Contributors:
-------------
- Vincent vinet <vincent.vinet@savoirfairelinux.com>
""",
"depends": [
'base',
'web',
],
"js": [
'static/src/js/datepicker.js',
],
"author": "Vincent Vinet",
"installable": True,
"active": False,
}

View File

@ -0,0 +1,35 @@
/*global openerp, _, $ */
openerp.web_datetime_options = function (instance) {
"use strict";
instance.web.form.FieldDatetime = instance.web.form.FieldDatetime.extend({
initialize_content: function() {
this._super();
var self = this;
if (this.datewidget) {
if (typeof this.options.datepicker === 'object') {
$.map(this.options.datepicker, function(value, key) {
self.datewidget.picker('option', key, value);
});
}
}
}
});
instance.web.form.FieldDate = instance.web.form.FieldDate.extend({
initialize_content: function() {
this._super();
var self = this;
if (this.datewidget) {
if (typeof this.options.datepicker === 'object') {
$.map(this.options.datepicker, function(value, key) {
self.datewidget.picker('option', key, value);
});
}
}
}
});
};