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

Hello, I'm using Odoo 17.2 online (so no direct access to code).

I'm creating a Scheduled Action for status updates on projects: 

every run, the automation should check all the projects that are not in cancelled or done statuses and update their realted project.update field base on 2 conditions:

  1. if the "remaining days" are 0 or 1 -> Set the project state update state to "At Risk" 
  2. if the "remaining days" are Set the project state update state to "Off Track" 

Where remaining days = Project.date - today() in days

My Dilemma: 

I can't calculate the "Remaing Days" value. I've already tried several python constructs but they gives me always errors. Is there an explanation document on how to use datetime date interval functions inside Odoo online (or Odoo Studio let's say) ?


Thanks in advance for the help

LucaB.

아바타
취소
베스트 답변

# Get today's date

today = datetime.date.today()

and to calculate the remaining days, you can loop through the projects and calculate it (try this I'm not sure)

remaining_days = (project.date - today).days

then Update the project status based on the condition

아바타
취소
작성자

Thanks Sayed. This works!

관련 게시물 답글 화면 활동
1
12월 22
4629
2
10월 24
1180
2
12월 20
5174
3
6월 25
722
1
7월 25
974