Hello!, I have a little problem I would like restrict years for choose in date pickers, previous year like min date and actual year like max date, I downloaded this module:
https://apps.odoo.com/apps/modules/9.0/web_widget_datepicker_options/
This module allows change the options of datepicker/datetimepicker in a specific date/datetime field, This module has this .js file:
odoo.define('web_widget_datepicker_options', function (require) {
"use strict";
var core = require('web.core');
var DateTimeWidget = require('web.datepicker').DateTimeWidget;
var DateWidget = require('web.datepicker').DateWidget;
DateTimeWidget.include({
start: function(parent, options) {
this._super.apply(this, arguments);
var self = this;
if (this.__parentedParent.options.datepicker) {
var options = this.__parentedParent.options.datepicker;
$.each(options, function(value, key) {
self.options[value] = key;
self.picker[value] = key;
self.picker.options[value] = key;
});
}
},
});
DateWidget.include({
start: function(parent, options) {
this._super.apply(this, arguments);
var self = this;
if (this.__parentedParent.options.datepicker) {
var options = this.__parentedParent.options.datepicker;
$.each(options, function(value, key) {
self.options[value] = key;
self.picker[value] = key;
self.picker.options[value] = key;
});
}
},
});
});
And It provides a xml demo for use the module:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="datepicker_options" model="ir.ui.view">
<field name="name">datepicker_options</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='access_rights']" position="inside">
<h2>Datepicker Demo</h2>
<label for="date"/>
<field name="date" options='{"datepicker": {" calendarWeeks ": false}}'/><br/>
<label for="create_date"/>
<field name="create_date" options="{'datepicker':{'calendarWeeks': false}}"/>
</xpath>
</field>
</record>
</odoo>
In the demo It uses the "calendarWeeks" option that if You set "True" It shows the number of the week in the left side of the calendar, by default Odoo shows in the datepicker a minDate and a maxDate, the minDate is the year 1900 and the maxDate is 100 years more from today.
In the demo I tried change the options with this:
{"minDate": "-1y"} (following the Datepicker API that the module provides http://api.jqueryui.com/datepicker/
But when I try input data in the date field I get the following error:
Uncaught TypeError: picker.options.minDate.year is not a function
Someone could help me? Thanks!!