Skip to Content
Menu
This question has been flagged
3 Replies
7092 Views

I have a view with a date field. The user must not select a date after today. How can I disable all days after the current date in Odoo datepi
.cker?

Avatar
Discard
Best Answer

Give

options="{'datepicker':{'maxDate': 'now'}}"
Avatar
Discard
Best Answer

Hello,

You refer below link.


https://stackoverflow.com/questions/61673978/how-to-disable-days-after-current-date-in-odoo-datepicker

Avatar
Discard
Best Answer

Hi Ernesto:

The syntax seems to be as follows:

<field name="...." options="{'datepicker': {'maxDate': '<date in local format>'}}"/>

You can also pass in a 'minDate' if you want to restrict the values in the field to a date range.

For example,

<field name="validity_date" options="{'datepicker': {'maxDate': '5/8/2020'}}"/>

However, there does not seem to be a way to pass the current date ('5/8/2020' in this example) as a variable. Hoping someone else can throw some light on how to pass the current date in place of the string '5/8/2020'. Using current_date does not seem to work within options.


Avatar
Discard