Browse Source

ADD web_datetime_options

pull/101/head
Vincent Vinet 10 years ago
parent
commit
34232639da
  1. 0
      web_datetime_options/__init__.py
  2. 37
      web_datetime_options/__openerp__.py
  3. 35
      web_datetime_options/static/src/js/datepicker.js

0
web_datetime_options/__init__.py

37
web_datetime_options/__openerp__.py

@ -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,
}

35
web_datetime_options/static/src/js/datepicker.js

@ -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);
});
}
}
}
});
};
Loading…
Cancel
Save