콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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!!



아바타
취소
관련 게시물 답글 화면 활동
1
7월 24
36
1
1월 18
4641
0
11월 24
1329
1
10월 22
3144
1
12월 19
10107