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

How to Disable past dates in Datepicker for a particular Date field in Odoov10?

I tried all solutions from google but still can not solve my problem.

아바타
취소
베스트 답변

Hi, i put this code inside a method but you can disable the method and try yourself to suit your needs :)

# this will generate pop up error message and date time module
from odoo.exceptions import UserError
from datetime import datetime

def disable_past_date(self):
selected = self.env['your.Model'].browse(self._context.get('active_ids', [])) # This will get your current record form
current_date = datetime.now() # this will get the today's date

if self.selected_date and self.selected_date < current_date: # compare todays date and selected date
raise UserError('The date selected is in the past.') # The error message

Best regards,

Altela (altelasoftware.com)

아바타
취소
관련 게시물 답글 화면 활동
1
12월 19
9914
0
11월 18
2589
0
11월 18
2298
1
5월 16
4725
3
3월 25
3939