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

I have a date field in a custom helpdesk ticket for a date, let's call that x_studio_warranty_end


In an integer field (call it x_studio_days_remaining_on_warranty) I want to compute how many days from TODAY that is. I.e. if the warranty end is '1/1/2024', I want my field to show '30'.




아바타
취소
작성자 베스트 답변

I ended up figuring it out after looking at many different places, maybe not the cleanest... 

for record in self:
if record.x_studio_warranty_end:​
​dt = datetime.datetime.now()
​dwarr = record.x_studio_warranty_end
​dwarrdt = datetime.datetime.combine(dwarr, datetime.datetime.min.time())
record['x_studio_days_remaining_on_warranty'] = (dwarrdt - dt).days​
아바타
취소
베스트 답변

You can also use Studio to change the widget of your date field to "Remaining Days". 

아바타
취소
관련 게시물 답글 화면 활동
2
6월 22
4608
2
6월 18
6143
2
11월 16
13770
2
2월 24
12643
0
10월 23
2981