Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
8192 มุมมอง

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?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Give

options="{'datepicker':{'maxDate': 'now'}}"
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello,

You refer below link.


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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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.


อวตาร
ละทิ้ง